From 18dfcc41a1d77d8ba337120a611198a5d5de77e1 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sun, 22 Nov 2020 20:24:13 +0100 Subject: [PATCH] Introduce AdminTag class and interface --- src/Admin/AbstractAdminTag.php | 753 ++++++++++++++++++ src/Admin/AdminTagInterface.php | 283 +++++++ .../AddDependencyCallsCompilerPass.php | 3 +- 3 files changed, 1038 insertions(+), 1 deletion(-) create mode 100644 src/Admin/AbstractAdminTag.php create mode 100644 src/Admin/AdminTagInterface.php diff --git a/src/Admin/AbstractAdminTag.php b/src/Admin/AbstractAdminTag.php new file mode 100644 index 0000000000..3667b83add --- /dev/null +++ b/src/Admin/AbstractAdminTag.php @@ -0,0 +1,753 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Sonata\AdminBundle\Admin; + +use Knp\Menu\FactoryInterface; +use Sonata\AdminBundle\Builder\DatagridBuilderInterface; +use Sonata\AdminBundle\Builder\FormContractorInterface; +use Sonata\AdminBundle\Builder\ListBuilderInterface; +use Sonata\AdminBundle\Builder\RouteBuilderInterface; +use Sonata\AdminBundle\Builder\ShowBuilderInterface; +use Sonata\AdminBundle\Datagrid\Pager; +use Sonata\AdminBundle\Exporter\DataSourceInterface; +use Sonata\AdminBundle\Filter\Persister\FilterPersisterInterface; +use Sonata\AdminBundle\Model\ModelManagerInterface; +use Sonata\AdminBundle\Route\RouteGeneratorInterface; +use Sonata\AdminBundle\Security\Handler\SecurityHandlerInterface; +use Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface; +use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Component\Validator\Validator\ValidatorInterface; + +/** + * @phpstan-template T of object + * @phpstan-implements AdminTagInterface + */ +abstract class AbstractAdminTag implements AdminTagInterface +{ + public const MOSAIC_ICON_CLASS = 'fa fa-th-large fa-fw'; + + /** + * The code related to the admin. + * + * @var string + */ + protected $code; + + /** + * The class name managed by the admin class. + * + * @var string + * + * @phpstan-var class-string + */ + protected $class; + + /** + * The base name controller used to generate the routing information. + * + * @var string + */ + protected $baseControllerName; + + /** + * @var string|null + */ + protected $label; + + /** + * @var array> + */ + protected $listModes = [ + 'list' => ['class' => 'fa fa-list fa-fw'], + 'mosaic' => ['class' => self::MOSAIC_ICON_CLASS], + ]; + + /** + * @var string + */ + protected $pagerType = Pager::TYPE_DEFAULT; + + /** + * The manager type to use for the admin. + * + * @var string|null + */ + protected $managerType; + + /** + * Roles and permissions per role. + * + * @var array 'role' => ['permission1', 'permission2'] + */ + protected $securityInformation = []; + + /** + * Whether or not to persist the filters in the session. + * + * NEXT_MAJOR: remove this property + * + * @var bool + * + * @deprecated since sonata-project/admin-bundle 3.34, to be removed in 4.0. + */ + protected $persistFilters = false; + + /** + * Component responsible for persisting filters. + * + * @var FilterPersisterInterface|null + */ + protected $filterPersister; + + /** + * The Entity or Document manager. + * + * @var ModelManagerInterface|null + */ + protected $modelManager; + + /** + * @var DataSourceInterface|null + */ + protected $dataSource; + + /** + * The related form contractor. + * + * @var FormContractorInterface|null + */ + protected $formContractor; + + /** + * The related view builder. + * + * @var ShowBuilderInterface|null + */ + protected $showBuilder; + + /** + * The related list builder. + * + * @var ListBuilderInterface|null + */ + protected $listBuilder; + + /** + * The related datagrid builder. + * + * @var DatagridBuilderInterface|null + */ + protected $datagridBuilder; + + /** + * The translator component. + * + * @var TranslatorInterface|null + */ + protected $translator; + + /** + * The configuration pool. + * + * @var Pool|null + */ + protected $configurationPool; + + /** + * The router instance. + * + * @var RouteGeneratorInterface|null + */ + protected $routeGenerator; + + /** + * @var ValidatorInterface|null + */ + protected $validator; + + /** + * @var SecurityHandlerInterface|null + */ + protected $securityHandler; + + /** + * @var FactoryInterface|null + */ + protected $menuFactory; + + /** + * @var RouteBuilderInterface|null + */ + protected $routeBuilder; + + /** + * @var LabelTranslatorStrategyInterface|null + */ + protected $labelTranslatorStrategy; + + /** + * NEXT_MAJOR: Change signature to __construct(string $code, string $class, string $baseControllerName). + */ + public function __construct($code, $class, $baseControllerName = null) + { + if (!\is_string($code)) { + @trigger_error(sprintf( + 'Passing other type than string as argument 1 for method %s() is deprecated since' + .' sonata-project/admin-bundle 3.65. It will accept only string in version 4.0.', + __METHOD__ + ), E_USER_DEPRECATED); + } + $this->code = $code; + + if (!\is_string($class)) { + @trigger_error(sprintf( + 'Passing other type than string as argument 2 for method %s() is deprecated since' + .' sonata-project/admin-bundle 3.65. It will accept only string in version 4.0.', + __METHOD__ + ), E_USER_DEPRECATED); + } + $this->class = $class; + + if (!\is_string($baseControllerName)) { + @trigger_error(sprintf( + 'Passing other type than string as argument 3 for method %s() is deprecated since' + .' sonata-project/admin-bundle 3.x. It will accept only string in version 4.0.', + __METHOD__ + ), E_USER_DEPRECATED); + } + $this->baseControllerName = $baseControllerName; + } + + abstract public function initialize(); + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setLabel($label) + { + $this->label = $label; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getLabel() + { + return $this->label; + } + + final public function showMosaicButton($isShown) + { + if ($isShown) { + $this->listModes['mosaic'] = ['class' => static::MOSAIC_ICON_CLASS]; + } else { + unset($this->listModes['mosaic']); + } + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setPagerType($pagerType) + { + $this->pagerType = $pagerType; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + * + * @return string + */ + public function getPagerType() + { + return $this->pagerType; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setManagerType($type) + { + $this->managerType = $type; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getManagerType() + { + if (null === $this->managerType) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no manager type is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no manager type.', +// static::class +// )); + } + + return $this->managerType; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setSecurityInformation(array $information) + { + $this->securityInformation = $information; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getSecurityInformation() + { + return $this->securityInformation; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setFilterPersister(?FilterPersisterInterface $filterPersister = null) + { + $this->filterPersister = $filterPersister; + // NEXT_MAJOR remove the deprecated property will be removed. Needed for persisted filter condition. + $this->persistFilters = true; + } + + final public function getFilterPersister(): FilterPersisterInterface + { + if (!$this->hasFilterPersister()) { + throw new \LogicException(sprintf('Admin "%s" has no filter persister.', static::class)); + } + + return $this->filterPersister; + } + + final public function hasFilterPersister(): bool + { + return null !== $this->filterPersister; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setModelManager(ModelManagerInterface $modelManager) + { + $this->modelManager = $modelManager; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getModelManager() + { + if (null === $this->modelManager) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no model manager is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no model manager.', +// static::class +// )); + } + + return $this->modelManager; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setDataSource(DataSourceInterface $dataSource) + { + $this->dataSource = $dataSource; + } + + /** + * NEXT_MAJOR: Change typehint for DataSourceInterface. + */ + public function getDataSource(): ?DataSourceInterface + { + if (null === $this->dataSource) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no data source is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no data source.', +// static::class +// )); + } + + return $this->dataSource; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setFormContractor(FormContractorInterface $formBuilder) + { + $this->formContractor = $formBuilder; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getFormContractor() + { + if (null === $this->formContractor) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no form contractor is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no form contractor.', +// static::class +// )); + } + + return $this->formContractor; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setShowBuilder(ShowBuilderInterface $showBuilder) + { + $this->showBuilder = $showBuilder; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getShowBuilder() + { + if (null === $this->showBuilder) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no show builder is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no show builder.', +// static::class +// )); + } + + return $this->showBuilder; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setListBuilder(ListBuilderInterface $listBuilder) + { + $this->listBuilder = $listBuilder; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getListBuilder() + { + if (null === $this->listBuilder) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no list build is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no list builder.', +// static::class +// )); + } + + return $this->listBuilder; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setDatagridBuilder(DatagridBuilderInterface $datagridBuilder) + { + $this->datagridBuilder = $datagridBuilder; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getDatagridBuilder() + { + if (null === $this->datagridBuilder) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no datagrid builder is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no datagrid builder.', +// static::class +// )); + } + + return $this->datagridBuilder; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setTranslator(TranslatorInterface $translator) + { + $this->translator = $translator; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getTranslator() + { + if (null === $this->translator) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no translator is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no translator.', +// static::class +// )); + } + + return $this->translator; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setConfigurationPool(Pool $configurationPool) + { + $this->configurationPool = $configurationPool; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getConfigurationPool() + { + if (null === $this->configurationPool) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + if ('sonata_deprecation_mute' !== (\func_get_args()[0] ?? null)) { + @trigger_error(sprintf( + 'Calling %s() when no pool is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); + } +// throw new \LogicException(sprintf( +// 'Admin "%s" has no pool.', +// static::class +// )); + } + + return $this->configurationPool; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setRouteGenerator(RouteGeneratorInterface $routeGenerator) + { + $this->routeGenerator = $routeGenerator; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getRouteGenerator() + { + if (null === $this->routeGenerator) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no route generator is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no route generator.', +// static::class +// )); + } + + return $this->routeGenerator; + } + + /** + * NEXT_MAJOR: Remove this method. + */ + public function setValidator($validator) + { + // NEXT_MAJOR: Move ValidatorInterface check to method signature + if (!$validator instanceof ValidatorInterface) { + throw new \InvalidArgumentException(sprintf( + 'Argument 1 must be an instance of %s', + ValidatorInterface::class + )); + } + + $this->validator = $validator; + } + + /** + * NEXT_MAJOR: Remove this method. + */ + public function getValidator() + { + @trigger_error(sprintf( + 'Calling %s() is deprecated since sonata-project/admin-bundle 3.x.', + __METHOD__, + ), E_USER_DEPRECATED); + + return $this->validator; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setSecurityHandler(SecurityHandlerInterface $securityHandler) + { + $this->securityHandler = $securityHandler; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getSecurityHandler() + { + if (null === $this->securityHandler) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no security handler is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no security handler.', +// static::class +// )); + } + + return $this->securityHandler; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setMenuFactory(FactoryInterface $menuFactory) + { + $this->menuFactory = $menuFactory; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getMenuFactory() + { + if (null === $this->menuFactory) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no security handler is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no security handler.', +// static::class +// )); + } + + return $this->menuFactory; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setRouteBuilder(RouteBuilderInterface $routeBuilder) + { + $this->routeBuilder = $routeBuilder; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getRouteBuilder() + { + if (null === $this->routeBuilder) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no route builder is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no route builder.', +// static::class +// )); + } + + return $this->routeBuilder; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function setLabelTranslatorStrategy(LabelTranslatorStrategyInterface $labelTranslatorStrategy) + { + $this->labelTranslatorStrategy = $labelTranslatorStrategy; + } + + /** + * @final since sonata-admin/admin-bundle 3.x + */ + public function getLabelTranslatorStrategy() + { + if (null === $this->labelTranslatorStrategy) { + // NEXT_MAJOR: Remove this deprecation and uncomment the following exception + @trigger_error(sprintf( + 'Calling %s() when no label translator strategy is set is deprecated since sonata-project/admin-bundle 3.x' + .' and will throw a LogicException in 4.0', + __METHOD__, + ), E_USER_DEPRECATED); +// throw new \LogicException(sprintf( +// 'Admin "%s" has no label translator strategy.', +// static::class +// )); + } + + return $this->labelTranslatorStrategy; + } +} diff --git a/src/Admin/AdminTagInterface.php b/src/Admin/AdminTagInterface.php new file mode 100644 index 0000000000..ebba728292 --- /dev/null +++ b/src/Admin/AdminTagInterface.php @@ -0,0 +1,283 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Sonata\AdminBundle\Admin; + +use Knp\Menu\FactoryInterface; +use Sonata\AdminBundle\Builder\DatagridBuilderInterface; +use Sonata\AdminBundle\Builder\FormContractorInterface; +use Sonata\AdminBundle\Builder\ListBuilderInterface; +use Sonata\AdminBundle\Builder\RouteBuilderInterface; +use Sonata\AdminBundle\Builder\ShowBuilderInterface; +use Sonata\AdminBundle\Exporter\DataSourceInterface; +use Sonata\AdminBundle\Filter\Persister\FilterPersisterInterface; +use Sonata\AdminBundle\Model\ModelManagerInterface; +use Sonata\AdminBundle\Route\RouteGeneratorInterface; +use Sonata\AdminBundle\Security\Handler\SecurityHandlerInterface; +use Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface; +use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Component\Validator\Validator\ValidatorInterface; + +/** + * This interface should be implemented to work with the AddDependencyCallsCompilerPass. + * All the setter are called by this compiler pass. + * + * @phpstan-template T of object + * + * @method void __construct(string $code, string $class, string $controller) + * @method void initialize() + * @method void setLabel(?string $label) + * @method void showMosaicButton(bool $isShown) + * @method void setPagerType(string $pagerType) + * @method string getPagerType() + * @method void setManagerType(string $managerType) + * @method void setSecurityInformation(array $information) + * @method void setFilterPersister(?FilterPersisterInterface $filterPersister = null) + * @method FilterPersisterInterface|null getFilterPersister() + * @method bool hasFilterPersister() + * @method void setModelManager(ModelManagerInterface $modelManager) + * @method void setDataSource(DataSourceInterface $dataSource) + * @method DataSourceInterface getDataSource() + * @method FormContractorInterface getFormContractor() + * @method void setShowBuilder(ShowBuilderInterface $showBuilder) + * @method ShowBuilderInterface getShowBuilder() + * @method Pool getConfigurationPool() + * @method void setRouteGenerator(RouteGeneratorInterface $routeGenerator) + * @method RouteGeneratorInterface getRouteGenerator() + */ +interface AdminTagInterface +{ + public const ADMIN_TAG = 'sonata.admin'; + + /** + * NEXT_MAJOR: Uncomment this method. + * + * The first and third argument are automatically injected by the AddDependencyCallsCompilerPass. + * + * @phpstan-param class-string $class + */ +// public function __construct(string $code, string $class, string $controller); + + /** + * NEXT_MAJOR: Uncomment this method. + * + * Define custom variable. + */ +// public function initialize(): void; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function setLabel(?string $label): void; + + /** + * @return string|null + */ + public function getLabel(); + + /** + * NEXT_MAJOR: Uncomment this method. + * + * Enable/Disable mosaic button for the admin screen. + */ +// public function showMosaicButton(bool $isShown): void; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function setPagerType(string $pagerType): void; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getPagerType(): string; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function setManagerType(string $managerType): void; + + /** + * @return string + */ + public function getManagerType(); + + /** + * NEXT_MAJOR: Uncomment this method. + * + * Set the roles and permissions per role. + */ +// public function setSecurityInformation(array $information): void; + + /** + * Return the roles and permissions per role + * - different permissions per role for the acl handler + * - one permission that has the same name as the role for the role handler + * This should be used by experimented users. + * + * @return array 'role' => ['permission', 'permission'] + */ + public function getSecurityInformation(); + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function setFilterPersister(?FilterPersisterInterface $filterPersister = null): void; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getFilterPersister(): ?FilterPersisterInterface; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function hasFilterPersister(): bool; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function setModelManager(ModelManagerInterface $modelManager): void; + + /** + * @return ModelManagerInterface + */ + public function getModelManager(); + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function setDataSource(DataSourceInterface $dataSource): void; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getDataSource(): DataSourceInterface; + + /** + * @return void + */ + public function setFormContractor(FormContractorInterface $formContractor); + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getFormContractor(): FormContractorInterface; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function setShowBuilder(ShowBuilderInterface $showBuilder): void; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getShowBuilder(): ShowBuilderInterface; + + /** + * @return void + */ + public function setListBuilder(ListBuilderInterface $listBuilder); + + /** + * @return ListBuilderInterface + */ + public function getListBuilder(); + + /** + * @return void + */ + public function setDatagridBuilder(DatagridBuilderInterface $datagridBuilder); + + /** + * @return DatagridBuilderInterface + */ + public function getDatagridBuilder(); + + /** + * @return void + */ + public function setTranslator(TranslatorInterface $translator); + + /** + * @return TranslatorInterface + */ + public function getTranslator(); + + /** + * @return void + */ + public function setConfigurationPool(Pool $pool); + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getConfigurationPool(): Pool; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function setRouteGenerator(RouteGeneratorInterface $routeGenerator): void; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getRouteGenerator(): RouteGeneratorInterface; + + /** + * NEXT_MAJOR: Remove this method. + * + * @return ValidatorInterface + */ + public function getValidator(); + + /** + * @return void + */ + public function setSecurityHandler(SecurityHandlerInterface $securityHandler); + + /** + * @return SecurityHandlerInterface + */ + public function getSecurityHandler(); + + /** + * @return void + */ + public function setMenuFactory(FactoryInterface $menuFactory); + + /** + * @return FactoryInterface + */ + public function getMenuFactory(); + + /** + * @return void + */ + public function setRouteBuilder(RouteBuilderInterface $routeBuilder); + + /** + * @return RouteBuilderInterface + */ + public function getRouteBuilder(); + + /** + * @return void + */ + public function setLabelTranslatorStrategy(LabelTranslatorStrategyInterface $labelTranslatorStrategy); + + /** + * @return LabelTranslatorStrategyInterface + */ + public function getLabelTranslatorStrategy(); +} diff --git a/src/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php b/src/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php index cc1d8f653e..5baa7c750d 100644 --- a/src/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php +++ b/src/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php @@ -14,6 +14,7 @@ namespace Sonata\AdminBundle\DependencyInjection\Compiler; use Doctrine\Inflector\InflectorFactory; +use Sonata\AdminBundle\Admin\AdminTagInterface; use Sonata\AdminBundle\Controller\CRUDController; use Sonata\AdminBundle\Datagrid\Pager; use Sonata\AdminBundle\Templating\TemplateRegistry; @@ -56,7 +57,7 @@ public function process(ContainerBuilder $container) 'icon' => $container->getParameter('sonata.admin.configuration.default_icon'), ]; - foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $tags) { + foreach ($container->findTaggedServiceIds(AdminTagInterface::ADMIN_TAG) as $id => $tags) { foreach ($tags as $attributes) { $definition = $container->getDefinition($id); $parentDefinition = null;