@param FormEvent $event

This methods loads current title data into the update form.
It uses an event to load only needed ids.
424864
public function hydrateUpdateForm(FormEvent $event)
    {
        $data = $event->getData();

        $title = CustomerTitleQuery::create()->findPk($data["title_id"]);

        if (null === $title) {
            $this->entityNotFound($data["title_id"]);
        }

        $data["default"] |= (bool) $title->getByDefault();

        $titleI18ns = CustomerTitleI18nQuery::create()
            ->filterById($data["title_id"])
            ->find()
            ->toKeyIndex('Locale')
        ;

        $i18n = &$data["i18n"];

        foreach ($data["i18n"] as $key => $value) {
            $i18n[$value["locale"]] = $value;

            unset($i18n[$key]);
        }


        /** @var \Thelia\Model\CustomerTitleI18n $titleI18n */
        foreach ($titleI18ns as $titleI18n) {
            $row = array();

            $row["locale"] = $locale = $titleI18n->getLocale();
            $row["short"] = $titleI18n->getShort();
            $row["long"] = $titleI18n->getLong();

            if (!isset($i18n[$locale])) {
                $i18n[$locale] = array();
            }

            $i18n[$locale] = array_merge($row, $i18n[$locale]);
        }

        $event->setData($data);
    }
6173
protected function getUpdateEvent($formData)
    {
        $brandUpdateEvent = new BrandUpdateEvent($formData['id']);

        $brandUpdateEvent
            ->setLogoImageId($formData['logo_image_id'])
            ->setVisible($formData['visible'])
            ->setLocale($formData['locale'])
            ->setTitle($formData['title'])
            ->setChapo($formData['chapo'])
            ->setDescription($formData['description'])
            ->setPostscriptum($formData['postscriptum'])
         ;

        return $brandUpdateEvent;
    }
1032969
public function onPreSetData(FormEvent $event)
    {
        /** @var CustomUrlAddData $data */
        $data = $event->getData();
        $location = $data->getLocation();
        if (null === $location) {
            return;
        }
        $contentInfo = $location->getContentInfo();
        $versionInfo = $this->contentService->loadVersionInfo($contentInfo);
        $contentLanguages = $versionInfo->languageCodes;

        $form = $event->getForm();

        $form->add(
            'language',
            ChoiceType::class,
            [
                'multiple' => false,
                'choice_loader' => new CallbackChoiceLoader($this->getCallableFilter($contentLanguages)),
                'choice_value' => 'languageCode',
                'choice_label' => 'name',
            ]
        );
    }
1282776
protected function getUpdateEvent($formData)
    {
        $event =  $this->getCreateOrUpdateEvent($formData);

        $event->setAddress($this->getExistingObject());

        return $event;
    }
937379
public function changeData(FormEvent $event)
    {
        $data = $event->getData();

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

        if ($data instanceof \Doctrine\Common\Collections\Collection) {
            $event->setData($data->getValues());
        } else {
            $event->setData(array_values($data));
        }
    }
4105
public function preSubmitData(FormEvent $event)
    {
        $form = $event->getForm();
        $data = $event->getData();

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

        foreach ($form as $name => $child) {
            if (!isset($data[$name])) {
                $form->remove($name);
            }
        }
    }
694053
public function processPreview(FormActionEvent $event): void
    {
        /** @var ContentCreateData|ContentUpdateData $data */
        $data = $event->getData();
        $form = $event->getForm();
        $languageCode = $form->getConfig()->getOption('languageCode');
        $referrerLocation = $event->getOption('referrerLocation');

        try {
            $contentDraft = $this->saveDraft($data, $languageCode);
            $contentLocation = $this->resolveLocation($contentDraft, $referrerLocation, $data);
            $url = $this->urlGenerator->generate('ezplatform.content.preview', [
                'locationId' => null !== $contentLocation ? $contentLocation->id : null,
                'contentId' => $contentDraft->id,
                'versionNo' => $contentDraft->getVersionInfo()->versionNo,
                'languageCode' => $languageCode,
            ]);
        } catch (Exception $e) {
            $this->notificationHandler->error(
                /** @Desc("Cannot save content draft.") */
                $this->translator->trans('error.preview', [], 'content_preview')
            );
            $url = $this->getContentEditUrl($data, $languageCode);
        }

        $event->setResponse(
            new RedirectResponse($url)
        );
    }
450987
public function buildCollection(FormEvent $event, $eventName)
    {
        $form = $event->getForm();

        for ($i = 0; $i < $this->options['max_items']; ++$i) {
            $required = $i < $this->options['min_items'] ? true : false;
            $displayed = $i < $this->options['min_items'] || $this->isDisplayable($event, $i, $eventName);

            $options = $this->options['options'];
            $options['required'] = isset($options['required']) ?
                $options['required'] && $required :
                $required
            ;
            $options['attr'] = array_replace(
                isset($options['attr']) ? $options['attr'] : array(),
                array(
                    'data-collection-id' => $this->options['collection_id'],
                    'data-display' => $displayed ? 'show' : 'hide',
                    'data-position' => $i,
                )
            );

            if (!$displayed) {
                self::disableConstraints($options);
            }

            $form->add($i, $this->options['type'], $options);

            $form->get($i)->add('__to_remove', CheckboxType::class, array(
                'mapped' => false,
                'required' => false,
                'data' => !$displayed,
                'attr' => array(
                    'class' => 'idci_collection_item_remove',
                ),
            ));
        }
    }
385732
protected function getUpdateEvent($formData)
    {
        // Build the product attributes array
        $productAttributes = [];

        foreach ($formData['product_attributes'] as $productId => $attributeAvIdList) {
            if (! empty($attributeAvIdList)) {
                $productAttributes[$productId] = explode(',', $attributeAvIdList);
            }
        }

        $saleUpdateEvent = new SaleUpdateEvent($formData['id']);

        $saleUpdateEvent
            ->setStartDate($formData['start_date'])
            ->setEndDate($formData['end_date'])
            ->setActive($formData['active'])
            ->setDisplayInitialPrice($formData['display_initial_price'])
            ->setPriceOffsetType($formData['price_offset_type'])
            ->setPriceOffsets($formData['price_offset'])
            ->setProducts($formData['products'])
            ->setProductAttributes($productAttributes)
            ->setLocale($formData['locale'])
            ->setTitle($formData['title'])
            ->setSaleLabel($formData['label'])
            ->setChapo($formData['chapo'])
            ->setDescription($formData['description'])
            ->setPostscriptum($formData['postscriptum'])
        ;

        return $saleUpdateEvent;
    }
101639
public function onBind(FormEvent $event)
    {
        // BC prevention for class extending this one.
        if (self::class !== \get_called_class()) {
            @trigger_error(
                __METHOD__.' is deprecated since 2.3 and will be renamed in 4.0.'
                .' Use '.__CLASS__.'::onSubmit instead.',
                E_USER_DEPRECATED
            );
        }

        $this->onSubmit($event);
    }
1295517
protected function getUpdateEvent($formData)
    {
        $contentUpdateEvent = new ContentUpdateEvent($formData['id']);

        $contentUpdateEvent
            ->setLocale($formData['locale'])
            ->setTitle($formData['title'])
            ->setChapo($formData['chapo'])
            ->setDescription($formData['description'])
            ->setPostscriptum($formData['postscriptum'])
            ->setVisible($formData['visible'])
            ->setDefaultFolder($formData['default_folder']);

        return $contentUpdateEvent;
    }
1100577
public function postSubmit(FormEvent $e)
    {
        if ($e->getForm()->has($this->property) && $e->getForm()->getRoot()->isValid()) {
            $menuItem = $e->getForm()->get($this->property)->getData();

            if ($menuItem->isAddToMenu()) {
                if (!$menuItem->getTitle()) {
                    $menuItem->setTitle((string)$e->getData());
                }
                $menuItem->setPath($this->provider->url($e->getData(), array('aliasing' => false)));
                $this->mm->addItem($menuItem);
            } elseif ($menuItem->getId()) {
                $this->mm->removeItem($menuItem);
            }
        }
    }
564525
protected function handle(Event $event): void
    {
        $method = 'apply'.ClassName::short($event);

        if (!method_exists($this, $method)) {
            return;
        }

        $this->$method($event);
    }
95336
public function preSetData(FormEvent $event)
    {
        $data = $event->getData();
        $form = $event->getForm();

        $fields = $form->getConfig()->getOption('fields');

        if (null === $data || '' === $data) {
            $data = [];
        }

        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
            throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
        }
        // Sorting values so that they display in sorted order of the attributes
        uasort($data, function ($a, $b) {
            return $a->getAttribute()->getSort() > $b->getAttribute()->getSort();
        });

        /**
         * @var string $name
         * @var Value  $value
         */
        foreach ($data as $name => $value) {
            //Do not add fields when there not in fields value when giving.
            if (!empty($fields) && !in_array($name, $fields)) {
                continue;
            }
            // Do not add fields dynamically if they've already been set statically.
            // This allows us to override the formtypes from inside the form type
            // that's calling this subscriber.
            if ($form->has($name)) {
                continue;
            }
            $form->add($name, ValueType::class, [
                'label' => $value->getAttribute()->getDisplayName(),
                'required' => $value->getAttribute()->getRequired(),
                'attribute' => $value->getAttribute(),
                'entity' => get_class($value),
                'value' => $value,
                'attr' => ['help_text' => $value->getAttribute()->getDescription()]
            ]);
        }
    }
656857
protected function populatePreviousData(Form $form) {
		$prepops = EventAttendee::config()->prepopulated_fields;
		if (!$prepops) {
			return;
		}
		$latestattendee = $this->registration->Attendees()
			->sort("LastEdited", "DESC")->first();
		if($latestattendee){
			$form->loadDataFrom($latestattendee, Form::MERGE_DEFAULT, $prepops);	
		}
	}
673426
protected function getUpdateEvent($formData)
    {
        $event = new IndexEngineDriverConfigurationEvent();

        $event->setId($formData["id"]);
        $event->setTitle($formData["title"]);

        return $event;
    }
888972
public function postSubmit(FormEvent $event)
    {
        $data = $event->getData();

        if ($this->itemDataClass !== null) {
            $itemMetadata = $this->getClassMetadata($this->itemDataClass);
            if ($itemMetadata !== null) {
                $this->cleanupCollection($data, $itemMetadata);
            }
        }
    }