Your project controllers should only contains actions as public methods 12
- Read doc
- Productivity
- Major
More information: https://insight.symfony.com/what-we-analyse/symfony.controller.non_action_public_method_in_controller_class
- $entityManager->getFilters()->disable('softdeleteable');
- // @codeCoverageIgnoreEnd
- }
- }
- public function configureFilters(Filters $filters): Filters
- {
- $filters->add(
- SoftDeleteFilter::new(
- 'deletedAt',
- $this->translator->trans('enabel_user.admin.form.showDeleted')
- );
- return parent::configureFilters($filters);
- }
- public function configureCrud(Crud $crud): Crud
- {
- return $crud
- ->setPageTitle(Crud::PAGE_INDEX, 'enabel_user.admin.title.manage_users')
- ->setPageTitle(Crud::PAGE_NEW, 'enabel_user.admin.title.new_user')
- ->setPageTitle(Crud::PAGE_EDIT, 'enabel_user.admin.title.edit_user')
- ->setSearchFields(['id', 'email', 'displayName'])
- ->setEntityPermission(User::ADMIN)
- ;
- }
- public function configureActions(Actions $actions): Actions
- {
- $actions = parent::configureActions($actions);
- /** @var User $currentUser */
- $currentUser = $this->getUser();
- }
- /**
- * @return iterable<FieldInterface>
- */
- public function configureFields(string $pageName): iterable
- {
- /** @var User $currentUser */
- $currentUser = $this->getUser();
- /** @var AdminContext $context */
- $context = $this->adminContextProvider->getContext();
- /**
- * @param EntityManagerInterface $entityManager
- * @param User $entityInstance
- */
- public function persistEntity(EntityManagerInterface $entityManager, $entityInstance): void
- {
- /** @var UserPasswordHasherInterface $hasher */
- $hasher = $this->container->get('security.password_hasher');
- $plainPassword = $entityInstance->getPlainPassword();
- if ($plainPassword !== null) {
- /**
- * @param EntityManagerInterface $entityManager
- * @param User $entityInstance
- */
- public function updateEntity(EntityManagerInterface $entityManager, $entityInstance): void
- {
- /** @var UserPasswordHasherInterface $hasher */
- $hasher = $this->container->get('security.password_hasher');
- $plainPassword = $entityInstance->getPlainPassword();
- if ($plainPassword !== null) {
- $entityInstance->setPassword($password);
- }
- parent::updateEntity($entityManager, $entityInstance);
- }
- public function impersonate(AdminContext $context): RedirectResponse
- {
- if (!$this->isGranted('ROLE_ALLOWED_TO_SWITCH')) {
- throw new HttpException(Response::HTTP_UNAUTHORIZED);
- }
- }
- return new RedirectResponse($referer);
- }
- public function restoreUser(AdminContext $context): Response
- {
- if (!$this->isGranted('ROLE_SUPER_ADMIN')) {
- throw new HttpException(Response::HTTP_UNAUTHORIZED);
- }
- use Symfony\Component\HttpFoundation\RedirectResponse;
- use Symfony\Component\Routing\Annotation\Route;
- class AzureController extends AbstractController
- {
- #[Route(path: '/azure/login', name: 'enabel_azure_login')]
- public function azureLogin(ClientRegistry $clientRegistry): RedirectResponse
- {
- return $clientRegistry
- ->getClient('azure_o365')
- ->redirect(
- []
- );
- }
- /** @codeCoverageIgnore */
- #[Route(path: '/azure/check', name: 'enabel_azure_check')]
- public function azureCheck(): void
- {
- throw new \LogicException('This method can be blank - Intercepted by the oauth2 client');
- }
- }
- use Symfony\Component\Routing\Annotation\Route;
- use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
- class LocalController extends AbstractController
- {
- #[Route(path: '/auth/login', name: 'enabel_login')]
- public function login(AuthenticationUtils $authenticationUtils, ParameterBagInterface $parameterBag): Response
- {
- if (null !== $this->getUser()) {
- /** @var string $defaultTarget */
- $defaultTarget = $parameterBag->get('enabel_user.login_redirect_route');
- }
- /**
- * @return never
- */
- #[Route(path: '/auth/logout', name: 'enabel_logout')]
- public function logout(): Response
- {
- throw new \LogicException('This method can be blank - Intercepted by the logout key on your firewall.');
- }
- }
damienlagae