<?php
/**
* @author Quentin CHATELAIN (contact@scaledev.fr)
* @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
* @license commercial
*/
declare(strict_types=1);
namespace Bluue\SalesBundle\EventSubscriber;
use App\Event\BundleRolesEvent;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class BundleRolesSubscriber implements EventSubscriberInterface
{
/**
* @var TranslatorInterface
*/
private TranslatorInterface $tr;
/**
* @param TranslatorInterface $tr
*/
public function __construct(
TranslatorInterface $tr
) {
$this->tr = $tr;
}
/**
* @return string[]
*/
public static function getSubscribedEvents(): array
{
return [
BundleRolesEvent::NAME => 'onLoad'
];
}
/**
* @param BundleRolesEvent $event
* @return void
*/
public function onLoad(BundleRolesEvent $event): void
{
$bundles = $event->getBundles();
$bundles[] = [
'select_name' => 'sales',
'name' => $this->tr->trans('Sales', [], 'SalesBundle')
];
$event->setBundles($bundles);
}
}