public function postSubmit(FormEvent $event)
    {
        $form = $event->getForm();
        if (!$form->isValid()) {
            return;
        }

        $entity = $event->getData();
        $formHash = $this->getFormHash($form);
        $entityConfiguration = $this->getTranslatableEntityConfiguration($entity);

        if (is_null($entityConfiguration)) {
            return null;
        }

        $this->translationsBackup[$formHash] = [];

        $entityData = [
            'object' => $entity,
            'idGetter' => $entityConfiguration['idGetter'],
            'alias' => $entityConfiguration['alias'],
            'fields' => [],
        ];

        $entityFields = $entityConfiguration['fields'];

        foreach ($entityFields as $fieldName => $fieldConfiguration) {
            if (!isset($this->submittedDataPlain[$formHash][$fieldName])) {
                continue;
            }

            $field = $this->submittedDataPlain[$formHash][$fieldName];

            foreach ($this->locales as $locale) {
                $entityData['fields'][$fieldName][$locale] = $field[$locale . '_' . $fieldName];
            }

            if ($this->masterLocale && isset($field[$this->masterLocale . '_' . $fieldName])) {
                $masterLocaleData = $field[$this->masterLocale . '_' . $fieldName];
                $setter = $fieldConfiguration['setter'];
                $entity->$setter($masterLocaleData);
            }
        }

        $this->translationsBackup[$formHash][] = $entityData;
    }
public function postSubmit(FormEvent $event)
    {
        $form = $event->getForm();
        if (!$form->isValid()) {
            return;
        }

        $entity = $event->getData();
        $formHash = $this->getFormHash($form);
        $entityConfiguration = $this->getTranslatableEntityConfiguration($entity);

        if (is_null($entityConfiguration)) {
            return null;
        }

        $this->translationsBackup[$formHash] = [];

        $entityData = [
            'object' => $entity,
            'idGetter' => $entityConfiguration['idGetter'],
            'alias' => $entityConfiguration['alias'],
            'fields' => [],
        ];

        $entityFields = $entityConfiguration['fields'];

        foreach ($entityFields as $fieldName => $fieldConfiguration) {
            if (!isset($this->submittedDataPlain[$formHash][$fieldName])) {
                continue;
            }

            $field = $this->submittedDataPlain[$formHash][$fieldName];

            foreach ($this->locales as $locale) {
                $entityData['fields'][$fieldName][$locale] = $field[$locale . '_' . $fieldName];
            }

            if ($this->masterLocale && isset($field[$this->masterLocale . '_' . $fieldName])) {
                $masterLocaleData = $field[$this->masterLocale . '_' . $fieldName];
                $setter = $fieldConfiguration['setter'];
                $entity->$setter($masterLocaleData);
            }
        }

        $this->translationsBackup[$formHash][] = $entityData;
    }
public function postSubmit ( FormEvent $ event ) { $ form = $ event -> getForm ( ) ; if ( ! $ form -> isValid ( ) ) { return ; } $ entity = $ event -> getData ( ) ; $ formHash = $ this -> getFormHash ( $ form ) ; $ entityConfiguration = $ this -> getTranslatableEntityConfiguration ( $ entity ) ; if ( is_null ( $ entityConfiguration ) ) { return null ; } $ this -> translationsBackup [ $ formHash ] = [ ] ; $ entityData = [ 'object' => $ entity , 'idGetter' => $ entityConfiguration [ 'idGetter' ] , 'alias' => $ entityConfiguration [ 'alias' ] , 'fields' => [ ] , ] ; $ entityFields = $ entityConfiguration [ 'fields' ] ; foreach ( $ entityFields as $ fieldName => $ fieldConfiguration ) { if ( ! isset ( $ this -> submittedDataPlain [ $ formHash ] [ $ fieldName ] ) ) { continue ; } $ field = $ this -> submittedDataPlain [ $ formHash ] [ $ fieldName ] ; foreach ( $ this -> locales as $ locale ) { $ entityData [ 'fields' ] [ $ fieldName ] [ $ locale ] = $ field [ $ locale . '_' . $ fieldName ] ; } if ( $ this -> masterLocale && isset ( $ field [ $ this -> masterLocale . '_' . $ fieldName ] ) ) { $ masterLocaleData = $ field [ $ this -> masterLocale . '_' . $ fieldName ] ; $ setter = $ fieldConfiguration [ 'setter' ] ; $ entity -> $ setter ( $ masterLocaleData ) ; } } $ this -> translationsBackup [ $ formHash ] [ ] = $ entityData ; }
Post submit.

@param FormEvent $event Event
Post submit .