Skip to content

Commit

Permalink
OP-325: Remove media preview
Browse files Browse the repository at this point in the history
  • Loading branch information
jkindly committed Jul 3, 2024
1 parent a9a5fdf commit b12e97d
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 75 deletions.
41 changes: 0 additions & 41 deletions src/Controller/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
}
9 changes: 0 additions & 9 deletions src/Resources/config/routing/admin/media.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 0 additions & 10 deletions src/Resources/views/Media/Crud/_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@
{{ form_row(form.saveWithOriginalName) }}
{{ form_row(form.collections) }}
{{ form_row(form.channels) }}

<a
href="#"
class="ui labeled button icon primary bitbag-cms-resource-preview"
data-bb-cms-preview-btn
data-url="{{ path('bitbag_sylius_cms_plugin_admin_media_preview', {'id': form.vars.data.id}) }}"
>
<i class="eye icon"></i>
{{ 'bitbag_sylius_cms_plugin.ui.preview'|trans }}
</a>
</div>
</div>
</div>
Expand Down
15 changes: 0 additions & 15 deletions src/Resources/views/Media/preview.html.twig

This file was deleted.

0 comments on commit b12e97d

Please sign in to comment.