custom/plugins/WbfkShopwareFixes/src/CoreFixes/Content/Media/Subscriber/MediaDeletionSubscriber.php line 35

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Wbfk\ShopwareFixes\CoreFixes\Content\Media\Subscriber;
  4. use Shopware\Core\Content\Media\Subscriber\MediaDeletionSubscriber as ShopwareMediaDeletionSubscriber;
  5. use Shopware\Core\Framework\Api\Context\AdminApiSource;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Event\BeforeDeleteEvent;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntitySearchedEvent;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class MediaDeletionSubscriber extends ShopwareMediaDeletionSubscriber implements EventSubscriberInterface
  10. {
  11. /** @noinspection PhpMissingParentConstructorInspection */
  12. public function __construct(
  13. private readonly ShopwareMediaDeletionSubscriber $decorated
  14. ) {
  15. }
  16. public static function getSubscribedEvents(): array
  17. {
  18. return parent::getSubscribedEvents();
  19. }
  20. public function securePrivateFolders(EntitySearchedEvent $event): void
  21. {
  22. // Allow admins to search private files
  23. if ($event->getContext()->getSource() instanceof AdminApiSource) {
  24. return;
  25. }
  26. $this->decorated->securePrivateFolders($event);
  27. }
  28. public function beforeDelete(BeforeDeleteEvent $event): void
  29. {
  30. $this->decorated->beforeDelete($event);
  31. }
  32. }