From 1c08c17f81151ebd529267f508f3c3be16e14988 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sat, 19 Dec 2020 12:27:45 +0100 Subject: [PATCH] Move getters to AdminInterface --- src/Admin/AdminInterface.php | 136 +++++++++++++++++ .../Admin/TaggedAdminInterface.php | 144 ++---------------- 2 files changed, 147 insertions(+), 133 deletions(-) diff --git a/src/Admin/AdminInterface.php b/src/Admin/AdminInterface.php index 5897a2d9e69..b40e6e21009 100644 --- a/src/Admin/AdminInterface.php +++ b/src/Admin/AdminInterface.php @@ -13,23 +13,45 @@ namespace Sonata\AdminBundle\Admin; +use Knp\Menu\FactoryInterface; use Knp\Menu\ItemInterface; +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\DatagridInterface; use Sonata\AdminBundle\Datagrid\ProxyQueryInterface; use Sonata\AdminBundle\DependencyInjection\Admin\TaggedAdminInterface; +use Sonata\AdminBundle\Exporter\DataSourceInterface; +use Sonata\AdminBundle\Filter\Persister\FilterPersisterInterface; +use Sonata\AdminBundle\Model\ModelManagerInterface; use Sonata\AdminBundle\Object\MetadataInterface; +use Sonata\AdminBundle\Route\RouteGeneratorInterface; +use Sonata\AdminBundle\Security\Handler\SecurityHandlerInterface; use Sonata\AdminBundle\Templating\MutableTemplateRegistryAwareInterface; +use Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface; use Sonata\Exporter\Source\SourceIteratorInterface; use Sonata\Form\Validator\ErrorElement; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Component\Validator\Validator\ValidatorInterface; /** * @author Thomas Rabaix * * NEXT_MAJOR: Add all these methods to the interface by uncommenting them. * + * @method string getPagerType() + * @method FilterPersisterInterface|null getFilterPersister() + * @method bool hasFilterPersister() + * @method DataSourceInterface getDataSource() + * @method FormContractorInterface getFormContractor() + * @method ShowBuilderInterface getShowBuilder() + * @method Pool getConfigurationPool() + * @method RouteGeneratorInterface getRouteGenerator() * @method array configureActionButtons(string $action, ?object $object = null) * @method string getSearchResultLink(object $object) * @method bool isCurrentRoute(string $name, ?string $adminCode) @@ -59,6 +81,120 @@ */ interface AdminInterface extends TaggedAdminInterface, AccessRegistryInterface, FieldDescriptionRegistryInterface, LifecycleHookProviderInterface, MenuBuilderInterface, ParentAdminInterface, UrlGeneratorInterface, MutableTemplateRegistryAwareInterface { + /** + * @return string|null + */ + public function getLabel(); + + /** + * @return array> + */ + public function getListModes(); + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getPagerType(): string; + + /** + * @return string + */ + public function getManagerType(); + + /** + * 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 getFilterPersister(): ?FilterPersisterInterface; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function hasFilterPersister(): bool; + + /** + * @return ModelManagerInterface + */ + public function getModelManager(); + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getDataSource(): DataSourceInterface; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getFormContractor(): FormContractorInterface; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getShowBuilder(): ShowBuilderInterface; + + /** + * @return ListBuilderInterface + */ + public function getListBuilder(); + + /** + * @return DatagridBuilderInterface + */ + public function getDatagridBuilder(); + + /** + * @return TranslatorInterface + */ + public function getTranslator(); + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getConfigurationPool(): Pool; + + /** + * NEXT_MAJOR: Uncomment this method. + */ +// public function getRouteGenerator(): RouteGeneratorInterface; + + /** + * NEXT_MAJOR: Remove this method. + * + * @return ValidatorInterface + * + * @deprecated since sonata-project/admin-bundle 3.83 and will be removed in 4.0 + */ + public function getValidator(); + + /** + * @return SecurityHandlerInterface + */ + public function getSecurityHandler(); + + /** + * @return FactoryInterface + */ + public function getMenuFactory(); + + /** + * @return RouteBuilderInterface + */ + public function getRouteBuilder(); + + /** + * @return LabelTranslatorStrategyInterface + */ + public function getLabelTranslatorStrategy(); + /** * Returns subjectClass/class/subclass name managed * - subclass name if subclass parameter is defined diff --git a/src/DependencyInjection/Admin/TaggedAdminInterface.php b/src/DependencyInjection/Admin/TaggedAdminInterface.php index 8ec4f8e5863..e1e20cb7334 100644 --- a/src/DependencyInjection/Admin/TaggedAdminInterface.php +++ b/src/DependencyInjection/Admin/TaggedAdminInterface.php @@ -43,25 +43,17 @@ * * @phpstan-template T of object * - * @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() + * @method void initialize() + * @method void setLabel(?string $label) + * @method void showMosaicButton(bool $isShown) + * @method void setPagerType(string $pagerType) + * @method void setManagerType(string $managerType) + * @method void setSecurityInformation(array $information) + * @method void setFilterPersister(?FilterPersisterInterface $filterPersister = null) + * @method void setModelManager(ModelManagerInterface $modelManager) + * @method void setDataSource(DataSourceInterface $dataSource) + * @method void setShowBuilder(ShowBuilderInterface $showBuilder) + * @method void setRouteGenerator(RouteGeneratorInterface $routeGenerator) */ interface TaggedAdminInterface { @@ -79,11 +71,6 @@ interface TaggedAdminInterface */ // public function setLabel(?string $label): void; - /** - * @return string|null - */ - public function getLabel(); - /** * NEXT_MAJOR: Uncomment this method. * @@ -91,31 +78,16 @@ public function getLabel(); */ // public function showMosaicButton(bool $isShown): void; - /** - * @return array> - */ - public function getListModes(); - /** * 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. * @@ -125,121 +97,56 @@ public function getManagerType(); */ // 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. * @@ -251,52 +158,23 @@ public function setConfigurationPool(Pool $pool); */ public function setValidator($validator); - /** - * NEXT_MAJOR: Remove this method. - * - * @return ValidatorInterface - * - * @deprecated since sonata-project/admin-bundle 3.83 and will be removed in 4.0 - */ - 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(); }