{{ render(controller('App\\Some\\GovnoController::govnoMethod', {'entity': entity.id})) }}
->add('role', ChoiceType::class, [
'choices' => [
'Пользователь' => Role::ROLE_USER,
'Автор' => Role::ROLE_AUTHOR,
'Редактор' => Role::ROLE_EDITOR,
'Главред' => Role::ROLE_CHIEF_EDITOR,
'Администратор' => Role::ROLE_ADMIN,
],
'required' => false,
'placeholder' => 'Роль',
])
class TestRepository1
{
/**
* @var ObjectRepository
*/
private $repository;
/**
* @var EntityManagerInterface
*/
private $em;
public function __construct(EntityManagerInterface $em)
{
$this->repository = $em->getRepository(Test::class);
$this->em = $em;
}
}
class TestRepository2
{
/**
* @var ObjectRepository
*/
private $repository;
/**
* @var EntityManagerInterface
*/
private $em;
public function __construct(EntityManagerInterface $em)
{
$this->repository = $em->getRepository(Test::class);
$this->em = $em;
}
}
$resolver->setDefaults([
'data_class' => // ссылка на класс
]);
class RequestSubscriber implements EventSubscriberInterface
{
/**
* @var TokenStorageInterface
*/
private $tokenStorage;
public function __construct(TokenStorageInterface $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
KernelEvents::REQUEST => 'onRequest'
];
}
/**
* @param GetResponseEvent $event
*/
public function onRequest(GetResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
}
if (!$token = $this->tokenStorage->getToken()) {
return;
}
$sessionUser = $token->getUser();
if ($sessionUser instanceof User) {
$this->tokenStorage->setToken(
new PostAuthenticationGuardToken($sessionUser, 'main', $sessionUser->getRoles())
);
}
}
}