src/Zicht/Bundle/PageBundle/Entity/ContentItem.php
public static function convert(ContentItemInterface $from, ContentItemInterface $to)
    {
        $reflectionFrom = new \ReflectionClass($from);
        $reflectionTo = new \ReflectionClass($to);

        foreach ($reflectionFrom->getProperties() as $property) {
            $property->setAccessible(true);
            $method = 'set' . ucfirst($property->getName());
            if ($reflectionTo->hasMethod($method)) {
                $to->$method($property->getValue($from));
            }
        }

        return $to;
    }
public static function convert(ContentItemInterface $from, ContentItemInterface $to)
    {
        $reflectionFrom = new \ReflectionClass($from);
        $reflectionTo = new \ReflectionClass($to);

        foreach ($reflectionFrom->getProperties() as $property) {
            $property->setAccessible(true);
            $method = 'set' . ucfirst($property->getName());
            if ($reflectionTo->hasMethod($method)) {
                $to->$method($property->getValue($from));
            }
        }

        return $to;
    }
public static function convert ( ContentItemInterface $ from , ContentItemInterface $ to ) { $ reflectionFrom = new \ ReflectionClass ( $ from ) ; $ reflectionTo = new \ ReflectionClass ( $ to ) ; foreach ( $ reflectionFrom -> getProperties ( ) as $ property ) { $ property -> setAccessible ( true ) ; $ method = 'set' . ucfirst ( $ property -> getName ( ) ) ; if ( $ reflectionTo -> hasMethod ( $ method ) ) { $ to -> $ method ( $ property -> getValue ( $ from ) ) ; } } return $ to ; }
Copies all properties from the source to the target, if the target has the specified properties.

@param ContentItemInterface $from
@param ContentItemInterface $to
@return ContentItemInterface
Copies all properties from the source to the target if the target has the specified properties .