vendor/bluue/planning-bundle/src/EventSubscriber/DashboardSubscriber.php line 47

Open in your IDE?
  1. <?php
  2. /**
  3.  * @author Thomas HERISSON (contact@scaledev.fr)
  4.  * @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
  5.  * @license commercial
  6.  */
  7. declare(strict_types=1);
  8. namespace Bluue\PlanningBundle\EventSubscriber;
  9. use App\Event\DashboardWidgetsEvent;
  10. use Symfony\Component\Security\Core\Security;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. class DashboardSubscriber implements EventSubscriberInterface
  13. {
  14.     /**
  15.      * @var Security
  16.      */
  17.     private Security $security;
  18.     /**
  19.      * @param Security $security
  20.      */
  21.     public function __construct(
  22.         Security $security
  23.     ) {
  24.         $this->security $security;
  25.     }
  26.     /**
  27.      * @return string[]
  28.      */
  29.     public static function getSubscribedEvents(): array
  30.     {
  31.         return [
  32.             DashboardWidgetsEvent::NAME => 'onLoad'
  33.         ];
  34.     }
  35.     /**
  36.      * @param DashboardWidgetsEvent $event
  37.      * @return void
  38.      */
  39.     public function onLoad(DashboardWidgetsEvent $event): void
  40.     {
  41.         if ($this->security->isGranted('ROLE__PLANNING__READ_ONLY')) {
  42.             $event->addWidget('planning_bundle__dashboard');
  43.         }
  44.     }
  45. }