diff --git a/src/ArgumentResolver/AdminContextResolver.php b/src/ArgumentResolver/AdminContextResolver.php index 810e1fcaed..34c7df41b8 100644 --- a/src/ArgumentResolver/AdminContextResolver.php +++ b/src/ArgumentResolver/AdminContextResolver.php @@ -3,7 +3,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\ArgumentResolver; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; @@ -15,11 +15,9 @@ if (interface_exists(ValueResolverInterface::class)) { final class AdminContextResolver implements ValueResolverInterface { - private AdminContextProvider $adminContextProvider; - - public function __construct(AdminContextProvider $adminContextProvider) - { - $this->adminContextProvider = $adminContextProvider; + public function __construct( + private AdminContextProviderInterface $adminContextProvider + ) { } public function resolve(Request $request, ArgumentMetadata $argument): iterable @@ -34,11 +32,9 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable } else { final class AdminContextResolver implements ArgumentValueResolverInterface { - private AdminContextProvider $adminContextProvider; - - public function __construct(AdminContextProvider $adminContextProvider) - { - $this->adminContextProvider = $adminContextProvider; + public function __construct( + private AdminContextProviderInterface $adminContextProvider + ) { } public function supports(Request $request, ArgumentMetadata $argument): bool diff --git a/src/ArgumentResolver/BatchActionDtoResolver.php b/src/ArgumentResolver/BatchActionDtoResolver.php index 61a4c1e01e..ede6fb148b 100644 --- a/src/ArgumentResolver/BatchActionDtoResolver.php +++ b/src/ArgumentResolver/BatchActionDtoResolver.php @@ -4,7 +4,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; use EasyCorp\Bundle\EasyAdminBundle\Dto\BatchActionDto; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; @@ -17,13 +17,10 @@ if (interface_exists(ValueResolverInterface::class)) { final class BatchActionDtoResolver implements ValueResolverInterface { - private AdminContextProvider $adminContextProvider; - private AdminUrlGeneratorInterface $adminUrlGenerator; - - public function __construct(AdminContextProvider $adminContextProvider, AdminUrlGeneratorInterface $adminUrlGenerator) - { - $this->adminContextProvider = $adminContextProvider; - $this->adminUrlGenerator = $adminUrlGenerator; + public function __construct( + private AdminContextProviderInterface $adminContextProvider, + private AdminUrlGeneratorInterface $adminUrlGenerator + ) { } public function resolve(Request $request, ArgumentMetadata $argument): iterable @@ -53,13 +50,10 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable } else { final class BatchActionDtoResolver implements ArgumentValueResolverInterface { - private AdminContextProvider $adminContextProvider; - private AdminUrlGeneratorInterface $adminUrlGenerator; - - public function __construct(AdminContextProvider $adminContextProvider, AdminUrlGeneratorInterface $adminUrlGenerator) - { - $this->adminContextProvider = $adminContextProvider; - $this->adminUrlGenerator = $adminUrlGenerator; + public function __construct( + private AdminContextProviderInterface $adminContextProvider, + private AdminUrlGeneratorInterface $adminUrlGenerator + ) { } public function supports(Request $request, ArgumentMetadata $argument): bool diff --git a/src/EventListener/CrudResponseListener.php b/src/EventListener/CrudResponseListener.php index 0afaeff968..4424b88103 100644 --- a/src/EventListener/CrudResponseListener.php +++ b/src/EventListener/CrudResponseListener.php @@ -3,7 +3,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\EventListener; use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\ViewEvent; @@ -14,13 +14,10 @@ */ final class CrudResponseListener { - private AdminContextProvider $adminContextProvider; - private Environment $twig; - - public function __construct(AdminContextProvider $adminContextProvider, Environment $twig) - { - $this->adminContextProvider = $adminContextProvider; - $this->twig = $twig; + public function __construct( + private AdminContextProviderInterface $adminContextProvider, + private Environment $twig + ) { } public function onKernelView(ViewEvent $event): void diff --git a/src/EventListener/ExceptionListener.php b/src/EventListener/ExceptionListener.php index 6bb54d0d22..6999fdbc4c 100644 --- a/src/EventListener/ExceptionListener.php +++ b/src/EventListener/ExceptionListener.php @@ -4,7 +4,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Exception\BaseException; use EasyCorp\Bundle\EasyAdminBundle\Exception\FlattenException; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\ExceptionEvent; use Twig\Environment; @@ -21,15 +21,11 @@ */ final class ExceptionListener { - private bool $kernelDebug; - private AdminContextProvider $adminContextProvider; - private Environment $twig; - - public function __construct(bool $kernelDebug, AdminContextProvider $adminContextProvider, Environment $twig) - { - $this->kernelDebug = $kernelDebug; - $this->adminContextProvider = $adminContextProvider; - $this->twig = $twig; + public function __construct( + private bool $kernelDebug, + private AdminContextProviderInterface $adminContextProvider, + private Environment $twig + ) { } public function onKernelException(ExceptionEvent $event) diff --git a/src/Factory/ActionFactory.php b/src/Factory/ActionFactory.php index c994567772..10b6b707f4 100644 --- a/src/Factory/ActionFactory.php +++ b/src/Factory/ActionFactory.php @@ -9,7 +9,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionConfigDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface; use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; use EasyCorp\Bundle\EasyAdminBundle\Translation\TranslatableMessageBuilder; @@ -24,17 +24,12 @@ */ final class ActionFactory { - private AdminContextProvider $adminContextProvider; - private AuthorizationCheckerInterface $authChecker; - private AdminUrlGeneratorInterface $adminUrlGenerator; - private ?CsrfTokenManagerInterface $csrfTokenManager; - - public function __construct(AdminContextProvider $adminContextProvider, AuthorizationCheckerInterface $authChecker, AdminUrlGeneratorInterface $adminUrlGenerator, ?CsrfTokenManagerInterface $csrfTokenManager = null) - { - $this->adminContextProvider = $adminContextProvider; - $this->authChecker = $authChecker; - $this->adminUrlGenerator = $adminUrlGenerator; - $this->csrfTokenManager = $csrfTokenManager; + public function __construct( + private AdminContextProviderInterface $adminContextProvider, + private AuthorizationCheckerInterface $authChecker, + private AdminUrlGeneratorInterface $adminUrlGenerator, + private ?CsrfTokenManagerInterface $csrfTokenManager = null + ) { } public function processEntityActions(EntityDto $entityDto, ActionConfigDto $actionsDto): void diff --git a/src/Factory/FieldFactory.php b/src/Factory/FieldFactory.php index d6375beb70..9a5209353c 100644 --- a/src/Factory/FieldFactory.php +++ b/src/Factory/FieldFactory.php @@ -19,7 +19,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TimeField; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\EaFormRowType; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; @@ -55,17 +55,12 @@ final class FieldFactory Types::TIME_IMMUTABLE => TimeField::class, ]; - private AdminContextProvider $adminContextProvider; - private AuthorizationCheckerInterface $authorizationChecker; - private iterable $fieldConfigurators; - private FormLayoutFactory $fieldLayoutFactory; - - public function __construct(AdminContextProvider $adminContextProvider, AuthorizationCheckerInterface $authorizationChecker, iterable $fieldConfigurators, FormLayoutFactory $fieldLayoutFactory) - { - $this->adminContextProvider = $adminContextProvider; - $this->authorizationChecker = $authorizationChecker; - $this->fieldConfigurators = $fieldConfigurators; - $this->fieldLayoutFactory = $fieldLayoutFactory; + public function __construct( + private AdminContextProviderInterface $adminContextProvider, + private AuthorizationCheckerInterface $authorizationChecker, + private iterable $fieldConfigurators, + private FormLayoutFactory $fieldLayoutFactory + ) { } public function processFields(EntityDto $entityDto, FieldCollection $fields): void diff --git a/src/Factory/FilterFactory.php b/src/Factory/FilterFactory.php index 4db429c7eb..b41052e590 100644 --- a/src/Factory/FilterFactory.php +++ b/src/Factory/FilterFactory.php @@ -15,7 +15,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Filter\EntityFilter; use EasyCorp\Bundle\EasyAdminBundle\Filter\NumericFilter; use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; /** * @author Yonel Ceruto @@ -23,8 +23,6 @@ */ final class FilterFactory { - private AdminContextProvider $adminContextProvider; - private iterable $filterConfigurators; private static array $doctrineTypeToFilterClass = [ 'json_array' => ArrayFilter::class, Types::SIMPLE_ARRAY => ArrayFilter::class, @@ -52,10 +50,10 @@ final class FilterFactory Types::TEXT => TextFilter::class, ]; - public function __construct(AdminContextProvider $adminContextProvider, iterable $filterConfigurators) - { - $this->adminContextProvider = $adminContextProvider; - $this->filterConfigurators = $filterConfigurators; + public function __construct( + private AdminContextProviderInterface $adminContextProvider, + private iterable $filterConfigurators + ) { } public function create(FilterConfigDto $filterConfig, FieldCollection $fields, EntityDto $entityDto): FilterCollection diff --git a/src/Factory/FormLayoutFactory.php b/src/Factory/FormLayoutFactory.php index 5d3893827c..17d55f49ae 100644 --- a/src/Factory/FormLayoutFactory.php +++ b/src/Factory/FormLayoutFactory.php @@ -180,7 +180,11 @@ private function linearizeLayoutConfiguration(FieldCollection $fields): void if ($fieldDto->isFormTab()) { $isTabActive = 0 === \count($tabs); - $tabId = sprintf('tab-%s', $fieldDto->getLabel() ? $slugger->slug(strip_tags($fieldDto->getLabel()))->lower()->toString() : ++$tabsWithoutLabelCounter); + $tabId = sprintf('tab-%s-%s', $fieldDto->getLabel() + ? $slugger->slug(strip_tags($fieldDto->getLabel()))->lower()->toString() + : ++$tabsWithoutLabelCounter, + uniqid(), + ); $fieldDto->setCustomOption(FormField::OPTION_TAB_ID, $tabId); $fieldDto->setCustomOption(FormField::OPTION_TAB_IS_ACTIVE, $isTabActive); diff --git a/src/Factory/MenuFactory.php b/src/Factory/MenuFactory.php index e099b6b129..2389e1f53b 100644 --- a/src/Factory/MenuFactory.php +++ b/src/Factory/MenuFactory.php @@ -11,7 +11,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Dto\MainMenuDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDto; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface; use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; @@ -24,19 +24,13 @@ */ final class MenuFactory implements MenuFactoryInterface { - private AdminContextProvider $adminContextProvider; - private AuthorizationCheckerInterface $authChecker; - private LogoutUrlGenerator $logoutUrlGenerator; - private AdminUrlGeneratorInterface $adminUrlGenerator; - private MenuItemMatcherInterface $menuItemMatcher; - - public function __construct(AdminContextProvider $adminContextProvider, AuthorizationCheckerInterface $authChecker, LogoutUrlGenerator $logoutUrlGenerator, AdminUrlGeneratorInterface $adminUrlGenerator, MenuItemMatcherInterface $menuItemMatcher) - { - $this->adminContextProvider = $adminContextProvider; - $this->authChecker = $authChecker; - $this->logoutUrlGenerator = $logoutUrlGenerator; - $this->adminUrlGenerator = $adminUrlGenerator; - $this->menuItemMatcher = $menuItemMatcher; + public function __construct( + private AdminContextProviderInterface $adminContextProvider, + private AuthorizationCheckerInterface $authChecker, + private LogoutUrlGenerator $logoutUrlGenerator, + private AdminUrlGeneratorInterface $adminUrlGenerator, + private MenuItemMatcherInterface $menuItemMatcher + ) { } /** diff --git a/src/Factory/PaginatorFactory.php b/src/Factory/PaginatorFactory.php index df07310e2b..66df23a9ff 100644 --- a/src/Factory/PaginatorFactory.php +++ b/src/Factory/PaginatorFactory.php @@ -4,20 +4,17 @@ use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Orm\EntityPaginatorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; /** * @author Javier Eguiluz */ final class PaginatorFactory { - private AdminContextProvider $adminContextProvider; - private EntityPaginatorInterface $entityPaginator; - - public function __construct(AdminContextProvider $adminContextProvider, EntityPaginatorInterface $entityPaginator) - { - $this->adminContextProvider = $adminContextProvider; - $this->entityPaginator = $entityPaginator; + public function __construct( + private AdminContextProviderInterface $adminContextProvider, + private EntityPaginatorInterface $entityPaginator + ) { } public function create(QueryBuilder $queryBuilder): EntityPaginatorInterface diff --git a/src/Field/Configurator/CommonPostConfigurator.php b/src/Field/Configurator/CommonPostConfigurator.php index 532b236e9e..8023701b74 100644 --- a/src/Field/Configurator/CommonPostConfigurator.php +++ b/src/Field/Configurator/CommonPostConfigurator.php @@ -7,7 +7,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use function Symfony\Component\String\u; use Twig\Markup; @@ -16,13 +16,10 @@ */ final class CommonPostConfigurator implements FieldConfiguratorInterface { - private AdminContextProvider $adminContextProvider; - private string $charset; - - public function __construct(AdminContextProvider $adminContextProvider, string $charset) - { - $this->adminContextProvider = $adminContextProvider; - $this->charset = $charset; + public function __construct( + private AdminContextProviderInterface $adminContextProvider, + private string $charset + ) { } public function supports(FieldDto $field, EntityDto $entityDto): bool diff --git a/src/Form/Extension/EaCrudFormTypeExtension.php b/src/Form/Extension/EaCrudFormTypeExtension.php index ac23fe22f5..d9d341250c 100644 --- a/src/Form/Extension/EaCrudFormTypeExtension.php +++ b/src/Form/Extension/EaCrudFormTypeExtension.php @@ -3,7 +3,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Form\Extension; use EasyCorp\Bundle\EasyAdminBundle\Dto\FormVarsDto; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\FormInterface; @@ -18,11 +18,9 @@ */ class EaCrudFormTypeExtension extends AbstractTypeExtension { - private AdminContextProvider $adminContextProvider; - - public function __construct(AdminContextProvider $adminContextProvider) - { - $this->adminContextProvider = $adminContextProvider; + public function __construct( + private AdminContextProviderInterface $adminContextProvider + ) { } public function configureOptions(OptionsResolver $resolver): void diff --git a/src/Inspector/DataCollector.php b/src/Inspector/DataCollector.php index f93fa94bb9..c9e44d1b96 100644 --- a/src/Inspector/DataCollector.php +++ b/src/Inspector/DataCollector.php @@ -4,7 +4,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector as BaseDataCollector; @@ -17,11 +17,9 @@ */ class DataCollector extends BaseDataCollector { - private AdminContextProvider $adminContextProvider; - - public function __construct(AdminContextProvider $adminContextProvider) - { - $this->adminContextProvider = $adminContextProvider; + public function __construct( + private AdminContextProviderInterface $adminContextProvider + ) { } public function reset(): void diff --git a/src/Menu/MenuItemMatcher.php b/src/Menu/MenuItemMatcher.php index f57b2d3500..a9714e6749 100644 --- a/src/Menu/MenuItemMatcher.php +++ b/src/Menu/MenuItemMatcher.php @@ -6,14 +6,14 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemMatcherInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDto; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; /** * @author Javier Eguiluz */ class MenuItemMatcher implements MenuItemMatcherInterface { - public function __construct(private AdminContextProvider $adminContextProvider) + public function __construct(private AdminContextProviderInterface $adminContextProvider) { } diff --git a/src/Orm/EntityRepository.php b/src/Orm/EntityRepository.php index 4dc6ae3c47..36ec3c07ce 100644 --- a/src/Orm/EntityRepository.php +++ b/src/Orm/EntityRepository.php @@ -19,7 +19,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\FormFactory; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\ComparisonType; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\Uid\Ulid; use Symfony\Component\Uid\Uuid; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; @@ -29,19 +29,13 @@ */ final class EntityRepository implements EntityRepositoryInterface { - private AdminContextProvider $adminContextProvider; - private ManagerRegistry $doctrine; - private EntityFactory $entityFactory; - private FormFactory $formFactory; - private EventDispatcherInterface $eventDispatcher; - - public function __construct(AdminContextProvider $adminContextProvider, ManagerRegistry $doctrine, EntityFactory $entityFactory, FormFactory $formFactory, EventDispatcherInterface $eventDispatcher) - { - $this->adminContextProvider = $adminContextProvider; - $this->doctrine = $doctrine; - $this->entityFactory = $entityFactory; - $this->formFactory = $formFactory; - $this->eventDispatcher = $eventDispatcher; + public function __construct( + private AdminContextProviderInterface $adminContextProvider, + private ManagerRegistry $doctrine, + private EntityFactory $entityFactory, + private FormFactory $formFactory, + private EventDispatcherInterface $eventDispatcher + ) { } public function createQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder diff --git a/src/Provider/AdminContextProvider.php b/src/Provider/AdminContextProvider.php index 9111811277..968d672c77 100644 --- a/src/Provider/AdminContextProvider.php +++ b/src/Provider/AdminContextProvider.php @@ -7,23 +7,17 @@ use Symfony\Component\HttpFoundation\RequestStack; /** - * Inject this in services that need to get the admin context object. - * * @author Javier Eguiluz */ -final class AdminContextProvider +final class AdminContextProvider implements AdminContextProviderInterface { - private RequestStack $requestStack; - - public function __construct(RequestStack $requestStack) - { - $this->requestStack = $requestStack; + public function __construct( + private RequestStack $requestStack + ) { } public function getContext(): ?AdminContext { - $currentRequest = $this->requestStack->getCurrentRequest(); - - return null !== $currentRequest ? $currentRequest->get(EA::CONTEXT_REQUEST_ATTRIBUTE) : null; + return $this->requestStack->getCurrentRequest()?->get(EA::CONTEXT_REQUEST_ATTRIBUTE); } } diff --git a/src/Provider/AdminContextProviderInterface.php b/src/Provider/AdminContextProviderInterface.php new file mode 100644 index 0000000000..c6c359719d --- /dev/null +++ b/src/Provider/AdminContextProviderInterface.php @@ -0,0 +1,12 @@ +adminContextProvider = $adminContextProvider; + public function __construct( + private AdminContextProviderInterface $adminContextProvider + ) { } public function getDefaultFields(string $pageName): array diff --git a/src/Router/AdminUrlGenerator.php b/src/Router/AdminUrlGenerator.php index 98db7ff08f..b4862cc033 100644 --- a/src/Router/AdminUrlGenerator.php +++ b/src/Router/AdminUrlGenerator.php @@ -6,7 +6,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\DashboardControllerInterface; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use EasyCorp\Bundle\EasyAdminBundle\Registry\DashboardControllerRegistry; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -16,20 +16,17 @@ final class AdminUrlGenerator implements AdminUrlGeneratorInterface { private bool $isInitialized = false; - private AdminContextProvider $adminContextProvider; - private UrlGeneratorInterface $urlGenerator; - private DashboardControllerRegistry $dashboardControllerRegistry; private ?string $dashboardRoute = null; private ?bool $includeReferrer = null; private array $routeParameters = []; private ?string $currentPageReferrer = null; private ?string $customPageReferrer = null; - public function __construct(AdminContextProvider $adminContextProvider, UrlGeneratorInterface $urlGenerator, DashboardControllerRegistry $dashboardControllerRegistry) - { - $this->adminContextProvider = $adminContextProvider; - $this->urlGenerator = $urlGenerator; - $this->dashboardControllerRegistry = $dashboardControllerRegistry; + public function __construct( + private AdminContextProviderInterface $adminContextProvider, + private UrlGeneratorInterface $urlGenerator, + private DashboardControllerRegistry $dashboardControllerRegistry + ) { } /** diff --git a/src/Security/SecurityVoter.php b/src/Security/SecurityVoter.php index e22eea05ea..c044ef61a0 100644 --- a/src/Security/SecurityVoter.php +++ b/src/Security/SecurityVoter.php @@ -7,7 +7,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDto; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\Voter\Voter; @@ -17,13 +17,10 @@ */ final class SecurityVoter extends Voter { - private AuthorizationCheckerInterface $authorizationChecker; - private AdminContextProvider $adminContextProvider; - - public function __construct(AuthorizationCheckerInterface $authorizationChecker, AdminContextProvider $adminContextProvider) - { - $this->authorizationChecker = $authorizationChecker; - $this->adminContextProvider = $adminContextProvider; + public function __construct( + private AuthorizationCheckerInterface $authorizationChecker, + private AdminContextProviderInterface $adminContextProvider, + ) { } protected function supports(string $permissionName, mixed $subject): bool diff --git a/src/Twig/EasyAdminTwigExtension.php b/src/Twig/EasyAdminTwigExtension.php index 816fbeb91c..da41343388 100644 --- a/src/Twig/EasyAdminTwigExtension.php +++ b/src/Twig/EasyAdminTwigExtension.php @@ -5,7 +5,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldLayoutDto; use EasyCorp\Bundle\EasyAdminBundle\Factory\FormLayoutFactory; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; +use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface; use Symfony\Component\DependencyInjection\ServiceLocator; @@ -26,15 +26,11 @@ */ class EasyAdminTwigExtension extends AbstractExtension implements GlobalsInterface { - private ServiceLocator $serviceLocator; - private AdminContextProvider $adminContextProvider; - private ?CsrfTokenManagerInterface $csrfTokenManager; - - public function __construct(ServiceLocator $serviceLocator, AdminContextProvider $adminContextProvider, ?CsrfTokenManagerInterface $csrfTokenManager) - { - $this->serviceLocator = $serviceLocator; - $this->adminContextProvider = $adminContextProvider; - $this->csrfTokenManager = $csrfTokenManager; + public function __construct( + private ServiceLocator $serviceLocator, + private AdminContextProviderInterface $adminContextProvider, + private ?CsrfTokenManagerInterface $csrfTokenManager + ) { } public function getFunctions(): array