vendor/uvdesk/core-framework/Tickets/QuickActionButtonCollection.php line 18

Open in your IDE?
  1. <?php
  2. namespace Webkul\UVDesk\CoreFrameworkBundle\Tickets;
  3. use Twig\Environment as TwigEnvironment;
  4. use Webkul\UVDesk\CoreFrameworkBundle\Services\UserService;
  5. use Webkul\UVDesk\CoreFrameworkBundle\Dashboard\DashboardTemplate;
  6. use Webkul\UVDesk\CoreFrameworkBundle\Framework\ExtendableComponentInterface;
  7. class QuickActionButtonCollection implements ExtendableComponentInterface
  8. {
  9.     private $collection = [];
  10.     
  11.     public function __construct(TwigEnvironment $twigDashboardTemplate $dashboardUserService $userService)
  12.     {
  13.         $this->twig $twig;
  14.         $this->dashboard $dashboard;
  15.         $this->userService $userService;
  16.     }
  17.     public function add(QuickActionButtonInterface $quickActionButton)
  18.     {
  19.         $this->collection[] = $quickActionButton;
  20.     }
  21.     public function injectTemplates()
  22.     {
  23.         return array_reduce($this->collection, function ($stream$quickActionButton) {
  24.             return $stream .= $quickActionButton->renderTemplate($this->twig);
  25.         }, '');
  26.     }
  27.     public function prepareAssets()
  28.     {
  29.         foreach ($this->collection as $quickActionButton) {
  30.             if ($quickActionButton::getRoles() != null) {
  31.                 foreach ($quickActionButton::getRoles() as $accessRole) {
  32.                     if ($this->userService->isAccessAuthorized($accessRole)) {
  33.                         $quickActionButton->prepareDashboard($this->dashboard);
  34.         
  35.                         break;
  36.                     }
  37.                 }
  38.             } else {
  39.                 $quickActionButton->prepareDashboard($this->dashboard);
  40.             }
  41.         }
  42.     }
  43. }