From ecf613017107750028c37982b790f713e85eb2d4 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 17 Dec 2020 00:13:57 +0100 Subject: [PATCH] Fix --- src/Admin/AbstractAdmin.php | 24 ++++--------------- .../Admin/AbstractTaggedAdmin.php | 4 ++-- .../Handler/AclSecurityHandlerInterface.php | 2 ++ .../Handler/SecurityHandlerInterface.php | 2 +- src/Util/AdminObjectAclData.php | 3 +++ 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/Admin/AbstractAdmin.php b/src/Admin/AbstractAdmin.php index 03fa3189417..a40841255d7 100644 --- a/src/Admin/AbstractAdmin.php +++ b/src/Admin/AbstractAdmin.php @@ -381,20 +381,9 @@ public function getDataSourceIterator(): SourceIteratorInterface // $fields[$key] = $field; } - if ($this->getDataSource()) { - $query = $datagrid->getQuery(); + $query = $datagrid->getQuery(); - return $this->getDataSource()->createIterator($query, $fields); - } - - @trigger_error(sprintf( - 'Using "%s()" without setting a "%s" instance in the admin is deprecated since sonata-project/admin-bundle 3.79' - .' and won\'t be possible in 4.0.', - __METHOD__, - DataSourceInterface::class - ), E_USER_DEPRECATED); - - return $this->getModelManager()->getDataSourceIterator($datagrid, $fields); + return $this->getDataSource()->createIterator($query, $fields); } /** @@ -819,11 +808,6 @@ public function getIdParameter(): string public function hasRoute(string $name): bool { - // NEXT_MAJOR: Remove this check. - if (!$this->routeGenerator) { - throw new \RuntimeException('RouteGenerator cannot be null'); - } - return $this->getRouteGenerator()->hasAdminRoute($this, $name); } @@ -860,12 +844,12 @@ public function generateObjectUrl(string $name, object $object, array $parameter public function generateUrl(string $name, array $parameters = [], int $referenceType = RoutingUrlGeneratorInterface::ABSOLUTE_PATH): string { - return $this->routeGenerator->generateUrl($this, $name, $parameters, $referenceType); + return $this->getRouteGenerator()->generateUrl($this, $name, $parameters, $referenceType); } public function generateMenuUrl(string $name, array $parameters = [], int $referenceType = RoutingUrlGeneratorInterface::ABSOLUTE_PATH): array { - return $this->routeGenerator->generateMenuUrl($this, $name, $parameters, $referenceType); + return $this->getRouteGenerator()->generateMenuUrl($this, $name, $parameters, $referenceType); } final public function setTemplateRegistry(MutableTemplateRegistryInterface $templateRegistry): void diff --git a/src/DependencyInjection/Admin/AbstractTaggedAdmin.php b/src/DependencyInjection/Admin/AbstractTaggedAdmin.php index 48a68f8cf4e..3ab94d684d8 100644 --- a/src/DependencyInjection/Admin/AbstractTaggedAdmin.php +++ b/src/DependencyInjection/Admin/AbstractTaggedAdmin.php @@ -254,7 +254,7 @@ public function getManagerType(): string /** * @final since sonata-admin/admin-bundle 3.x * - * @param array $information + * @param array $information */ public function setSecurityInformation(array $information): void { @@ -264,7 +264,7 @@ public function setSecurityInformation(array $information): void /** * @final since sonata-admin/admin-bundle 3.x * - * @return array + * @return array */ public function getSecurityInformation(): array { diff --git a/src/Security/Handler/AclSecurityHandlerInterface.php b/src/Security/Handler/AclSecurityHandlerInterface.php index 05b1a6d5b87..feca3960627 100644 --- a/src/Security/Handler/AclSecurityHandlerInterface.php +++ b/src/Security/Handler/AclSecurityHandlerInterface.php @@ -66,6 +66,8 @@ public function addObjectOwner(MutableAclInterface $acl, ?UserSecurityIdentity $ /** * Add the object class ACE's to the object ACL. + * + * @param array $roleInformation */ public function addObjectClassAces(MutableAclInterface $acl, array $roleInformation = []): void; diff --git a/src/Security/Handler/SecurityHandlerInterface.php b/src/Security/Handler/SecurityHandlerInterface.php index 6751858a11e..2b28d1b8392 100644 --- a/src/Security/Handler/SecurityHandlerInterface.php +++ b/src/Security/Handler/SecurityHandlerInterface.php @@ -31,7 +31,7 @@ public function isGranted(AdminInterface $admin, $attributes, ?object $object = public function getBaseRole(AdminInterface $admin): string; /** - * @return array + * @return array */ public function buildSecurityInformation(AdminInterface $admin): array; diff --git a/src/Util/AdminObjectAclData.php b/src/Util/AdminObjectAclData.php index 8744942eefd..20f89616ce4 100644 --- a/src/Util/AdminObjectAclData.php +++ b/src/Util/AdminObjectAclData.php @@ -211,6 +211,9 @@ public function getSecurityHandler(): AclSecurityHandlerInterface return $securityHandler; } + /** + * @return array + */ public function getSecurityInformation(): array { return $this->getSecurityHandler()->buildSecurityInformation($this->admin);