vendor/bluue/projects-bundle/src/EventSubscriber/ProjectViewTabsSubscriber.php line 40

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Bluue\ProjectsBundle\EventSubscriber;
  4. use Bluue\ProjectsBundle\Event\ProjectViewTabsEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Contracts\Translation\TranslatorInterface;
  7. class ProjectViewTabsSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var TranslatorInterface
  11.      */
  12.     private TranslatorInterface $tr;
  13.     /**
  14.      * @param TranslatorInterface $tr
  15.      */
  16.     public function __construct(TranslatorInterface $tr)
  17.     {
  18.         $this->tr $tr;
  19.     }
  20.     /**
  21.      * @return string[]
  22.      */
  23.     public static function getSubscribedEvents(): array
  24.     {
  25.         return [
  26.             ProjectViewTabsEvent::NAME => 'viewTabs'
  27.         ];
  28.     }
  29.     /**
  30.      * @param ProjectViewTabsEvent $event
  31.      * @return void
  32.      */
  33.     public function viewTabs(ProjectViewTabsEvent $event): void
  34.     {
  35.         $tabs $event->getTabs();
  36.         $newTabs = [
  37.             [
  38.                 'name' => $this->tr->trans('Time spent', [], 'ProjectsBundle'),
  39.                 'icon' => 'fas fa-calendar-alt',
  40.                 'key' => 'time_spent',
  41.                 'render' => 'Bluue\\ProjectsBundle\\Controller\\TaskController::timeSpent',
  42.                 'params' => [
  43.                     'id' => $event->getId(),
  44.                     'entity' => 'project'
  45.                 ],
  46.             ]
  47.         ];
  48.         $event->setTabs(array_merge($tabs$newTabs));
  49.     }
  50. }