Feature #34783

Provide utility method to get unproxied class name

Added by Adrian Föder over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Persistence
Target version:
-
Start date:
2012-03-13
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

In some cases, get_class($object) returns the Doctrine proxy class; and not the actual, intended class name.

In Doctrine itself, there is a method Doctrine\Common\Util\ClassUtils...

   /**
     * Get the real class name of an object (even if its a proxy)
     *
     * @param object
     * @return string
     */
    public static function getClass($object)

which basically does some str_replace; unfortunately it doesn't work with FLOW3 proxies due to a different naming scheme.

A possibility is to provide a method that

if ($object instanceof \Doctrine\ORM\Proxy\Proxy) {
   return get_parent_class($object);
}

but that's probably not very clean.

So, a reliable method to achieve that should be provided by FLOW3.


Related issues

Is duplicate of TYPO3.Flow - Task #34426: How to receive the correct class name for an object?ResolvedAndreas Förthner2012-02-29

Actions

Also available in: Atom PDF