public function normalize($entity)
    {
        $key = $this->mapping['fieldname'];
        $accessor = 'get' . ucfirst($key);

        $outerCollection = $entity->$accessor();
        if (!$outerCollection instanceof RepeatingFieldCollection) {
            $collection = new RepeatingFieldCollection($this->em, $this->mapping);
            $collection->setName($key);

            if (is_array($outerCollection)) {
                foreach ($outerCollection as $group => $fields) {
                    if (is_array($fields)) {
                        $collection->addFromArray($fields, $group, $entity);
                    }
                }
            }

            $setter = 'set' . ucfirst($key);
            $entity->$setter($collection);
        }
    }
public function normalize($entity)
    {
        $key = $this->mapping['fieldname'];
        $accessor = 'get' . ucfirst($key);

        $outerCollection = $entity->$accessor();
        if (!$outerCollection instanceof RepeatingFieldCollection) {
            $collection = new RepeatingFieldCollection($this->em, $this->mapping);
            $collection->setName($key);

            if (is_array($outerCollection)) {
                foreach ($outerCollection as $group => $fields) {
                    if (is_array($fields)) {
                        $collection->addFromArray($fields, $group, $entity);
                    }
                }
            }

            $setter = 'set' . ucfirst($key);
            $entity->$setter($collection);
        }
    }
public function normalize ( $ entity ) { $ key = $ this -> mapping [ 'fieldname' ] ; $ accessor = 'get' . ucfirst ( $ key ) ; $ outerCollection = $ entity -> $ accessor ( ) ; if ( ! $ outerCollection instanceof RepeatingFieldCollection ) { $ collection = new RepeatingFieldCollection ( $ this -> em , $ this -> mapping ) ; $ collection -> setName ( $ key ) ; if ( is_array ( $ outerCollection ) ) { foreach ( $ outerCollection as $ group => $ fields ) { if ( is_array ( $ fields ) ) { $ collection -> addFromArray ( $ fields , $ group , $ entity ) ; } } } $ setter = 'set' . ucfirst ( $ key ) ; $ entity -> $ setter ( $ collection ) ; } }
Normalize step ensures that we have correctly hydrated objects at the collection
and entity level.

@param object $entity
Normalize step ensures that we have correctly hydrated objects at the collection and entity level .