public function processRemoveDraft(FormActionEvent $event) { /** @var \EzSystems\RepositoryForms\Data\Role\PolicyCreateData|\EzSystems\RepositoryForms\Data\Role\PolicyUpdateData $data */ $data = $event->getData(); $event->setResponse(new FormProcessingDoneResponse($this->router->generate('admin_roleView', ['roleId' => $data->initialRole->id]))); $this->notify('role.policy.notification.draft_removed', [], 'role'); $this->notify('role.notification.draft_removed', [], 'role'); }
public function processUpdate(FormActionEvent $event) { /** @var \EzSystems\RepositoryForms\Data\Language\LanguageUpdateData|\EzSystems\RepositoryForms\Data\Language\LanguageCreateData $languageData */ $languageData = $event->getData(); if ($languageData->isNew()) { $this->notify('language.notification.created', ['%languageName%' => $languageData->name], 'language'); } else { $this->notify('language.notification.updated', ['%languageName%' => $languageData->name], 'language'); } $event->setResponse(new FormProcessingDoneResponse($this->router->generate('admin_languageview', ['languageId' => $languageData->getId()]))); }
public function processUpdate(FormActionEvent $event) { /** @var \EzSystems\RepositoryForms\Data\ContentTypeGroup\ContentTypeGroupUpdateData|\EzSystems\RepositoryForms\Data\ContentTypeGroup\ContentTypeGroupCreateData $data */ $data = $event->getData(); if ($data->isNew()) { $this->notify('content_type.group.notification.created', ['%identifier%' => $data->identifier], 'content_type'); } else { $this->notify('content_type.group.notification.updated', ['%identifier%' => $data->identifier], 'content_type'); } $event->setResponse(new FormProcessingDoneResponse($this->router->generate('admin_contenttypeGroupList'))); }
public function processUpdate(FormActionEvent $event) { /** @var \EzSystems\RepositoryForms\Data\Section\SectionUpdateData|\EzSystems\RepositoryForms\Data\Section\SectionCreateData $sectionData */ $sectionData = $event->getData(); if ($sectionData->isNew()) { $this->notify('section.notification.created', ['%sectionName%' => $sectionData->name], 'section'); } else { $this->notify('section.notification.updated', ['%sectionName%' => $sectionData->name], 'section'); } $event->setResponse(new FormProcessingDoneResponse($this->router->generate('admin_sectionview', ['sectionId' => $sectionData->getId()]))); }
public function processUpdate(FormActionEvent $event) { /** @var \EzSystems\RepositoryForms\Data\Section\SectionUpdateData|\EzSystems\RepositoryForms\Data\Section\SectionCreateData $sectionData */ $sectionData = $event->getData(); if ($sectionData->isNew()) { $section = $this->sectionService->createSection($sectionData); } else { $section = $this->sectionService->updateSection($sectionData->section, $sectionData); } $sectionData->setSection($section); }
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 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 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 processUpdate(FormActionEvent $event) { /** @var \EzSystems\RepositoryForms\Data\ContentTypeGroup\ContentTypeGroupUpdateData|\EzSystems\RepositoryForms\Data\ContentTypeGroup\ContentTypeGroupCreateData $data */ $data = $event->getData(); if ($data->isNew()) { $contentTypeGroup = $this->contentTypeService->createContentTypeGroup($data); } else { $this->contentTypeService->updateContentTypeGroup($data->contentTypeGroup, $data); $contentTypeGroup = $this->contentTypeService->loadContentTypeGroup($data->getId()); } $data->setContentTypeGroup($contentTypeGroup); }
public function processRemoveContentTypeDraft(FormActionEvent $event) { /** @var ContentTypeDraft $contentTypeDraft */ $contentTypeDraft = $event->getData()->contentTypeDraft; $languageCode = $event->getOption('languageCode'); // Redirect response will be different if we're dealing with an existing ContentType or a newly created one, which has been discarded. try { // This will throw a NotFoundException if a published version doesn't exist for this ContentType. $this->contentTypeService->loadContentType($contentTypeDraft->id); $response = $this->generateRedirectResponse($contentTypeDraft, $languageCode); } catch (NotFoundException $e) { // ContentTypeDraft was newly created, but then discarded. // Redirect to the ContentTypeGroup view. $response = new FormProcessingDoneResponse($this->router->generate('admin_contenttypeGroupView', ['contentTypeGroupId' => $contentTypeDraft->contentTypeGroups[0]->id])); } $event->setResponse($response); $this->notify('content_type.notification.draft_removed', [], 'content_type'); }
public function processRemoveDraft(FormActionEvent $event) { /** @var RoleDraft $roleDraft */ $roleDraft = $event->getData()->roleDraft; // Redirect response will be different if we're dealing with an existing Role, // or a newly created one which has been discarded. try { // This will throw a NotFoundException if a published version doesn't exist for this Role. $this->roleService->loadRole($roleDraft->id); $response = new FormProcessingDoneResponse($this->router->generate('admin_roleView', ['roleId' => $roleDraft->id])); } catch (NotFoundException $e) { // RoleDraft was newly created, but then discarded. // Redirect to the role list view. $response = new FormProcessingDoneResponse($this->router->generate('admin_roleList')); } $event->setResponse($response); $this->notify('role.notification.draft_removed', [], 'role'); }
public function processUpdate(FormActionEvent $event) { /** @var \EzSystems\RepositoryForms\Data\Language\LanguageUpdateData|\EzSystems\RepositoryForms\Data\Language\LanguageCreateData $languageData */ $languageData = $event->getData(); if ($languageData->isNew()) { $language = $this->languageService->createLanguage($languageData); } else { // As there is no update struct for language service, we first update name if it has changed $language = $languageData->language; if ($languageData->name !== $language->name) { $language = $this->languageService->updateLanguageName($language, $languageData->name); } // check if we should enable / disable language if ($languageData->enabled !== $language->enabled) { if ($languageData->enabled) { $language = $this->languageService->enableLanguage($language); } else { $language = $this->languageService->disableLanguage($language); } } } $languageData->setLanguage($language); }
public function processRemoveContentTypeDraft(FormActionEvent $event) { $contentTypeDraft = $event->getData()->contentTypeDraft; $this->contentTypeService->deleteContentType($contentTypeDraft); if (isset($this->options['redirectRouteAfterPublish'])) { $event->setResponse(new RedirectResponse($this->router->generate($this->options['redirectRouteAfterPublish']))); } }
public function processRemoveDraft(FormActionEvent $event) { /** @var \EzSystems\RepositoryForms\Data\Role\PolicyCreateData|\EzSystems\RepositoryForms\Data\Role\PolicyUpdateData $data */ $data = $event->getData(); if (!$data->isNew()) { $this->roleService->removePolicyByRoleDraft($data->roleDraft, $data->policyDraft); } $this->roleService->deleteRoleDraft($data->roleDraft); }
/** * Returns the role data for the event. * * @param FormActionEvent $event * * @return \EzSystems\RepositoryForms\Data\Role\RoleData */ protected function getRoleData(FormActionEvent $event) { return $event->getData(); }
public function processRemoveDraft(FormActionEvent $event) { /** @var RoleDraft $roleDraft */ $roleDraft = $event->getData()->roleDraft; $this->roleService->deleteRoleDraft($roleDraft); }