diff --git a/bundle/Controller/ContentEditController.php b/bundle/Controller/ContentEditController.php index 3799db3ba..05d9ee72d 100644 --- a/bundle/Controller/ContentEditController.php +++ b/bundle/Controller/ContentEditController.php @@ -15,6 +15,7 @@ use eZ\Publish\API\Repository\Values\Content\VersionInfo; use eZ\Publish\Core\Base\Exceptions\BadStateException; use EzSystems\RepositoryForms\Content\View\ContentCreateDraftView; +use EzSystems\RepositoryForms\Content\View\ContentCreateView; use EzSystems\RepositoryForms\Content\View\ContentEditView; use EzSystems\RepositoryForms\Data\Content\CreateContentDraftData; use EzSystems\RepositoryForms\Data\Mapper\ContentCreateMapper; @@ -73,10 +74,15 @@ public function __construct( * @param int $parentLocationId Location the content should be a child of * @param \Symfony\Component\HttpFoundation\Request $request * - * @return \EzSystems\RepositoryForms\Content\View\ContentEditView|\Symfony\Component\HttpFoundation\Response + * @return \EzSystems\RepositoryForms\Content\View\ContentCreateView|\Symfony\Component\HttpFoundation\Response + * + * @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType + * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException + * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException */ public function createWithoutDraftAction($contentTypeIdentifier, $language, $parentLocationId, Request $request) { + $parentLocation = $this->locationService->loadLocation($parentLocationId); $contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier); $data = (new ContentCreateMapper())->mapToFormData($contentType, [ 'mainLanguageCode' => $language, @@ -95,9 +101,11 @@ public function createWithoutDraftAction($contentTypeIdentifier, $language, $par } } - return new ContentEditView(null, [ + return new ContentCreateView(null, [ 'form' => $form->createView(), 'languageCode' => $language, + 'contentType' => $contentType, + 'parentLocation' => $parentLocation, ]); } diff --git a/bundle/DependencyInjection/Configuration/Parser/ContentEdit.php b/bundle/DependencyInjection/Configuration/Parser/ContentEdit.php index 1a20100aa..73c208f0e 100644 --- a/bundle/DependencyInjection/Configuration/Parser/ContentEdit.php +++ b/bundle/DependencyInjection/Configuration/Parser/ContentEdit.php @@ -30,6 +30,9 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder) ->scalarNode('edit') ->info('Template to use for content edit form rendering.') ->end() + ->scalarNode('create') + ->info('Template to use for content create form rendering.') + ->end() ->scalarNode('create_draft') ->info('Template to use for content draft creation rendering.') ->end() @@ -55,6 +58,14 @@ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerIn ); } + if (!empty($settings['templates']['create'])) { + $contextualizer->setContextualParameter( + 'content_edit.templates.create', + $currentScope, + $settings['templates']['create'] + ); + } + if (!empty($settings['templates']['create_draft'])) { $contextualizer->setContextualParameter( 'content_edit.templates.create_draft', diff --git a/bundle/Resources/config/ezpublish_default_settings.yml b/bundle/Resources/config/ezpublish_default_settings.yml index 16f84e198..0b68664ed 100644 --- a/bundle/Resources/config/ezpublish_default_settings.yml +++ b/bundle/Resources/config/ezpublish_default_settings.yml @@ -3,6 +3,7 @@ parameters: ezsettings.default.user_registration.templates.form: "EzSystemsRepositoryFormsBundle:Content:content_edit.html.twig" ezsettings.default.user_registration.templates.confirmation: "EzSystemsRepositoryFormsBundle:User:register_confirmation.html.twig" ezsettings.default.content_edit.templates.edit: "EzSystemsRepositoryFormsBundle:Content:content_edit.html.twig" + ezsettings.default.content_edit.templates.create: "EzSystemsRepositoryFormsBundle:Content:content_edit.html.twig" ezsettings.default.content_edit.templates.create_draft: "EzSystemsRepositoryFormsBundle:Content:content_create_draft.html.twig" ezsettings.default.limitation_value_templates: - { template: 'EzSystemsRepositoryFormsBundle::limitation_values.html.twig', priority: 0 } diff --git a/bundle/Resources/config/services.yml b/bundle/Resources/config/services.yml index 06a7f78b3..308f1ca04 100644 --- a/bundle/Resources/config/services.yml +++ b/bundle/Resources/config/services.yml @@ -265,6 +265,7 @@ services: - [setViewTemplate, ['EzSystems\RepositoryForms\UserRegister\View\UserRegisterFormView', "$user_registration.templates.form$"]] - [setViewTemplate, ['EzSystems\RepositoryForms\UserRegister\View\UserRegisterConfirmView', "$user_registration.templates.confirmation$"]] - [setViewTemplate, ['EzSystems\RepositoryForms\Content\View\ContentEditView', "$content_edit.templates.edit$"]] + - [setViewTemplate, ['EzSystems\RepositoryForms\Content\View\ContentCreateView', "$content_edit.templates.create$"]] - [setViewTemplate, ['EzSystems\RepositoryForms\Content\View\ContentCreateDraftView', "$content_edit.templates.create_draft$"]] - [setPagelayout, ["$pagelayout$"]] diff --git a/lib/Content/View/ContentCreateView.php b/lib/Content/View/ContentCreateView.php new file mode 100644 index 000000000..3799901b5 --- /dev/null +++ b/lib/Content/View/ContentCreateView.php @@ -0,0 +1,12 @@ +