diff --git a/src/Controller/MediaController.php b/src/Controller/MediaController.php index 112dc19d..1963b860 100755 --- a/src/Controller/MediaController.php +++ b/src/Controller/MediaController.php @@ -73,33 +73,6 @@ public function downloadMediaAction(Request $request): Response return $response; } - public function previewAction(Request $request): Response - { - $configuration = $this->getRequestConfiguration($request); - - $this->isGrantedOr403($configuration, ResourceActions::CREATE); - /** @var MediaInterface $media */ - $media = $this->getResourceInterface($request); - $form = $this->getFormForResource($configuration, $media); - $mediaTemplate = null; - - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $this->setMediaLocales($media, $request); - $this->setMediaPathIfExists($media); - $mediaTemplate = $this->mediaProviderResolver->resolveProvider($media)->getTemplate(); - } - $this->formErrorsFlashHelper->addFlashErrors($form); - - return $this->render($configuration->getTemplate(ResourceActions::CREATE . '.html'), [ - 'metadata' => $this->metadata, - 'resource' => $media, - 'mediaTemplate' => $mediaTemplate, - $this->metadata->getName() => $media, - ]); - } - public function setMediaProviderResolver(MediaProviderResolverInterface $mediaProviderResolver): void { $this->mediaProviderResolver = $mediaProviderResolver; @@ -117,18 +90,4 @@ private function getMediaForRequestCode(RequestConfiguration $configuration, Req return $this->mediaResourceResolver->findOrLog($code); } - - private function setMediaLocales(MediaInterface $media, Request $request): void - { - $defaultLocale = $this->getParameter('locale'); - $media->setFallbackLocale($request->get('_locale', $defaultLocale)); - $media->setCurrentLocale($request->get('_locale', $defaultLocale)); - } - - private function setMediaPathIfExists(MediaInterface $media): void - { - if (null !== $media->getFile() || null !== $media->getPath()) { - $this->setResourceMediaPath($media); - } - } } diff --git a/src/Resources/config/routing/admin/media.yml b/src/Resources/config/routing/admin/media.yml index 33360ee0..cfd9e3a6 100644 --- a/src/Resources/config/routing/admin/media.yml +++ b/src/Resources/config/routing/admin/media.yml @@ -17,15 +17,6 @@ bitbag_sylius_cms_plugin_admin_media: icon: file type: sylius.resource -bitbag_sylius_cms_plugin_admin_media_preview: - path: /media/preview/{id} - methods: [GET, POST, PUT] - defaults: - _controller: bitbag_sylius_cms_plugin.controller.media.overriden::previewAction - _sylius: - template: "@BitBagSyliusCmsPlugin/Media/preview.html.twig" - id: null - bitbag_sylius_cms_plugin_admin_ajax_media_by_name_phrase: path: /ajax/media/search methods: [GET] diff --git a/src/Resources/views/Media/Crud/_form.html.twig b/src/Resources/views/Media/Crud/_form.html.twig index 3cfced71..b8f08aa0 100755 --- a/src/Resources/views/Media/Crud/_form.html.twig +++ b/src/Resources/views/Media/Crud/_form.html.twig @@ -16,16 +16,6 @@ {{ form_row(form.saveWithOriginalName) }} {{ form_row(form.collections) }} {{ form_row(form.channels) }} - - - - {{ 'bitbag_sylius_cms_plugin.ui.preview'|trans }} - diff --git a/src/Resources/views/Media/preview.html.twig b/src/Resources/views/Media/preview.html.twig deleted file mode 100644 index 6e18f258..00000000 --- a/src/Resources/views/Media/preview.html.twig +++ /dev/null @@ -1,15 +0,0 @@ -{% extends '@SyliusShop/layout.html.twig' %} - -{% block metatags %} - -{% endblock %} - -{% block content %} -
-
- {% if mediaTemplate != null %} - {% include mediaTemplate %} - {% endif %} -
-
-{% endblock %}