public function processRemoveDraft(FormActionEvent $event)
 {
     /** @var \EzSystems\RepositoryForms\Data\Content\ContentCreateData|\EzSystems\RepositoryForms\Data\Content\ContentUpdateData $data */
     $data = $event->getData();
     $form = $event->getForm();
     if ($data->isNew()) {
         return;
     }
     $this->contentService->deleteVersion($data->contentDraft->getVersionInfo());
     $url = $this->router->generate(UrlAliasRouter::URL_ALIAS_ROUTE_NAME, ['contentId' => $data->contentDraft->id], UrlGeneratorInterface::ABSOLUTE_URL);
     $event->setResponse(new RedirectResponse($url));
 }
 public function testConstruct()
 {
     $form = $this->getMock('\\Symfony\\Component\\Form\\FormInterface');
     $data = new stdClass();
     $clickedButton = 'fooButton';
     $options = ['languageCode' => 'eng-GB', 'foo' => 'bar'];
     $event = new FormActionEvent($form, $data, $clickedButton, $options);
     self::assertSame($form, $event->getForm());
     self::assertSame($data, $event->getData());
     self::assertSame($clickedButton, $event->getClickedButton());
     self::assertSame($options, $event->getOptions());
 }
 public function processPublish(FormActionEvent $event)
 {
     /** @var \EzSystems\RepositoryForms\Data\User\UserCreateData $data */
     if (!($data = $event->getData()) instanceof UserCreateData) {
         return;
     }
     $form = $event->getForm();
     $this->saveDraft($data, $form->getConfig()->getOption('languageCode'));
     $redirectUrl = $this->router->generate('ez_user_register_confirmation');
     $event->setResponse(new RedirectResponse($redirectUrl));
     $event->stopPropagation();
 }
 public function processRemoveFieldDefinition(FormActionEvent $event)
 {
     /** @var \eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft $contentTypeDraft */
     $contentTypeDraft = $event->getData()->contentTypeDraft;
     // Accessing FieldDefinition user selection through the form and not the data,
     // as "selected" is not a property of FieldDefinitionData.
     /** @var \Symfony\Component\Form\FormInterface $fieldDefForm */
     foreach ($event->getForm()->get('fieldDefinitionsData') as $fieldDefForm) {
         if ($fieldDefForm->get('selected')->getData() === true) {
             $this->contentTypeService->removeFieldDefinition($contentTypeDraft, $fieldDefForm->getData()->fieldDefinition);
         }
     }
 }