Form/EventListener/CharacteristicsResizeListener.php
public function onSubmit(FormEvent $event)
    {
        $data = $event->getData();

        if (null === $data) {
            $data = array();
        }

        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
            throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
        }

        foreach ($this->schema->getGroups() as $schemaGroup) {
            foreach ($schemaGroup->getDefinitions() as $schemaDefinition) {
                if (true === $schemaDefinition->getVirtual()) {
                    continue;
                }
                $identifier = $schemaDefinition->getIdentifier();
                if ($data->offsetExists($identifier)) {
                    /** @var CharacteristicInterface $characteristic */
                    $characteristic = $data->offsetGet($identifier);
                    if ($this->isNullOrEqualsParentData($characteristic)) {
                        $data->offsetUnset($identifier);
                        $this->em->remove($characteristic);
                    } else {
                        $characteristic->setIdentifier($identifier);
                    }
                } else {
                    throw new \RuntimeException(sprintf('Missing [%s] characteristic data.', $identifier));
                }
            }
        }

        $event->setData($data);
    }
public function onSubmit(FormEvent $event)
    {
        $data = $event->getData();

        if (null === $data) {
            $data = array();
        }

        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
            throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
        }

        foreach ($this->schema->getGroups() as $schemaGroup) {
            foreach ($schemaGroup->getDefinitions() as $schemaDefinition) {
                if (true === $schemaDefinition->getVirtual()) {
                    continue;
                }
                $identifier = $schemaDefinition->getIdentifier();
                if ($data->offsetExists($identifier)) {
                    /** @var CharacteristicInterface $characteristic */
                    $characteristic = $data->offsetGet($identifier);
                    if ($this->isNullOrEqualsParentData($characteristic)) {
                        $data->offsetUnset($identifier);
                        $this->em->remove($characteristic);
                    } else {
                        $characteristic->setIdentifier($identifier);
                    }
                } else {
                    throw new \RuntimeException(sprintf('Missing [%s] characteristic data.', $identifier));
                }
            }
        }

        $event->setData($data);
    }
public function onSubmit ( FormEvent $ event ) { $ data = $ event -> getData ( ) ; if ( null === $ data ) { $ data = array ( ) ; } if ( ! is_array ( $ data ) && ! ( $ data instanceof \ Traversable && $ data instanceof \ ArrayAccess ) ) { throw new UnexpectedTypeException ( $ data , 'array or (\Traversable and \ArrayAccess)' ) ; } foreach ( $ this -> schema -> getGroups ( ) as $ schemaGroup ) { foreach ( $ schemaGroup -> getDefinitions ( ) as $ schemaDefinition ) { if ( true === $ schemaDefinition -> getVirtual ( ) ) { continue ; } $ identifier = $ schemaDefinition -> getIdentifier ( ) ; if ( $ data -> offsetExists ( $ identifier ) ) { /** @var CharacteristicInterface $characteristic */ $ characteristic = $ data -> offsetGet ( $ identifier ) ; if ( $ this -> isNullOrEqualsParentData ( $ characteristic ) ) { $ data -> offsetUnset ( $ identifier ) ; $ this -> em -> remove ( $ characteristic ) ; } else { $ characteristic -> setIdentifier ( $ identifier ) ; } } else { throw new \ RuntimeException ( sprintf ( 'Missing [%s] characteristic data.' , $ identifier ) ) ; } } } $ event -> setData ( $ data ) ; }
Submit event handler.

@param \Symfony\Component\Form\FormEvent $event
@throws \Symfony\Component\Form\Exception\UnexpectedTypeException
@throws \RuntimeException
Submit event handler .