src/EventSubscriber/Order/PhotoPermissionSubscriber.php line 22

  1. <?php
  2. /*
  3.  * This file is part of the Pellipop project.
  4.  *
  5.  * (c) Mobizel
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace App\EventSubscriber\Order;
  12. use App\Entity\Order\OrderItemPhoto;
  13. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  14. use Vich\UploaderBundle\Event\Event;
  15. class PhotoPermissionSubscriber implements EventSubscriberInterface
  16. {
  17.     public function postUpload(Event $event)
  18.     {
  19.         $object $event->getObject();
  20.         if ($object instanceof OrderItemPhoto) {
  21.             @chmod($object->getFile()->getPathname(), 0666);
  22.         }
  23.     }
  24.     public static function getSubscribedEvents()
  25.     {
  26.         return [
  27.             'vich_uploader.post_upload' => 'postUpload',
  28.         ];
  29.     }
  30. }