public function registerReflectionIdAccessors($classNames, $idPropertyName)
    {
        foreach ((array)$classNames as $className) {
            $getter = function ($entity) use ($className, $idPropertyName) {
                $reflectionClass = new ReflectionClass($className);
                $property        = $reflectionClass->getProperty($idPropertyName);
                $property->setAccessible(true);

                return $property->getValue($entity);
            };
            $setter = function ($entity, $id) use ($className, $idPropertyName) {
                $reflectionClass = new ReflectionClass($className);
                $property        = $reflectionClass->getProperty($idPropertyName);
                $property->setAccessible(true);
                $property->setValue($entity, $id);
            };
            $this->registerIdAccessors($classNames, $getter, $setter);
        }
    }
public function registerReflectionIdAccessors($classNames, $idPropertyName)
    {
        foreach ((array)$classNames as $className) {
            $getter = function ($entity) use ($className, $idPropertyName) {
                $reflectionClass = new ReflectionClass($className);
                $property        = $reflectionClass->getProperty($idPropertyName);
                $property->setAccessible(true);

                return $property->getValue($entity);
            };
            $setter = function ($entity, $id) use ($className, $idPropertyName) {
                $reflectionClass = new ReflectionClass($className);
                $property        = $reflectionClass->getProperty($idPropertyName);
                $property->setAccessible(true);
                $property->setValue($entity, $id);
            };
            $this->registerIdAccessors($classNames, $getter, $setter);
        }
    }
public function registerReflectionIdAccessors ( $ classNames , $ idPropertyName ) { foreach ( ( array ) $ classNames as $ className ) { $ getter = function ( $ entity ) use ( $ className , $ idPropertyName ) { $ reflectionClass = new ReflectionClass ( $ className ) ; $ property = $ reflectionClass -> getProperty ( $ idPropertyName ) ; $ property -> setAccessible ( true ) ; return $ property -> getValue ( $ entity ) ; } ; $ setter = function ( $ entity , $ id ) use ( $ className , $ idPropertyName ) { $ reflectionClass = new ReflectionClass ( $ className ) ; $ property = $ reflectionClass -> getProperty ( $ idPropertyName ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( $ entity , $ id ) ; } ; $ this -> registerIdAccessors ( $ classNames , $ getter , $ setter ) ; } }
Registers accessors that use reflection to set Id properties in the input classes

@param   string|array $classNames     The name or list of names of classes whose Id accessors we're registering
@param   string       $idPropertyName The name of the Id property we're registering

@return  void
Registers accessors that use reflection to set Id properties in the input classes