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