-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate some Pool methods related to groups and fix array shapes #6659
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,24 @@ | |
use Symfony\Component\PropertyAccess\PropertyAccessorInterface; | ||
|
||
/** | ||
* @psalm-type Group = array{ | ||
* label: string, | ||
* label_catalogue: string, | ||
* icon: string, | ||
* item_adds: array, | ||
* items: array<array-key, array{ | ||
* admin?: string, | ||
* label?: string, | ||
* roles: list<string>, | ||
* route?: string, | ||
* router_absolute: bool, | ||
* route_params: array<string, string> | ||
* }>, | ||
* keep_open: bool, | ||
* on_top: bool, | ||
* roles: list<string> | ||
* } | ||
* | ||
* @final since sonata-project/admin-bundle 3.52 | ||
* | ||
* @author Thomas Rabaix <[email protected]> | ||
|
@@ -38,6 +56,8 @@ class Pool | |
|
||
/** | ||
* @var array | ||
* @phpstan-var array<string, array<string, mixed>> | ||
* @psalm-var array<string, Group> | ||
*/ | ||
protected $adminGroups = []; | ||
|
||
|
@@ -137,10 +157,19 @@ public function __construct( | |
} | ||
|
||
/** | ||
* @return array<string, array<string, AdminInterface>> | ||
* NEXT_MAJOR: Remove this method. | ||
* | ||
* @deprecated since sonata-project/admin-bundle 3.x and will be removed in 4.0. | ||
* | ||
* @return array | ||
*/ | ||
public function getGroups() | ||
{ | ||
@trigger_error(sprintf( | ||
'Method "%s()" is deprecated since sonata-project/admin-bundle 3.x and will be removed in version 4.0.', | ||
__METHOD__ | ||
), E_USER_DEPRECATED); | ||
|
||
$groups = $this->adminGroups; | ||
|
||
foreach ($this->adminGroups as $name => $adminGroup) { | ||
|
@@ -153,6 +182,10 @@ public function getGroups() | |
} | ||
|
||
/** | ||
* NEXT_MAJOR: Remove this method. | ||
* | ||
* @deprecated since sonata-project/admin-bundle 3.x and will be removed in 4.0. | ||
* | ||
* Returns whether an admin group exists or not. | ||
* | ||
* @param string $group | ||
|
@@ -161,11 +194,26 @@ public function getGroups() | |
*/ | ||
public function hasGroup($group) | ||
{ | ||
@trigger_error(sprintf( | ||
'Method "%s()" is deprecated since sonata-project/admin-bundle 3.x and will be removed in version 4.0.', | ||
__METHOD__ | ||
), E_USER_DEPRECATED); | ||
|
||
return isset($this->adminGroups[$group]); | ||
} | ||
|
||
/** | ||
* @return array | ||
* @phpstan-return array<string, array{ | ||
* label: string, | ||
* label_catalogue: string, | ||
* icon: string, | ||
* item_adds: array, | ||
* items: array<array-key, AdminInterface>, | ||
* keep_open: bool, | ||
* on_top: bool, | ||
* roles: list<string> | ||
* }> | ||
*/ | ||
public function getDashboardGroups() | ||
{ | ||
|
@@ -198,6 +246,10 @@ public function getDashboardGroups() | |
} | ||
|
||
/** | ||
* NEXT_MAJOR: Remove this method. | ||
* | ||
* @deprecated since sonata-project/admin-bundle 3.x and will be removed in 4.0. | ||
* | ||
* Returns all admins related to the given $group. | ||
* | ||
* @param string $group | ||
|
@@ -208,6 +260,11 @@ public function getDashboardGroups() | |
*/ | ||
public function getAdminsByGroup($group) | ||
{ | ||
@trigger_error(sprintf( | ||
'Method "%s()" is deprecated since sonata-project/admin-bundle 3.x and will be removed in version 4.0.', | ||
__METHOD__ | ||
), E_USER_DEPRECATED); | ||
|
||
if (!isset($this->adminGroups[$group])) { | ||
throw new \InvalidArgumentException(sprintf('Group "%s" not found in admin pool.', $group)); | ||
} | ||
|
@@ -449,6 +506,9 @@ public function getContainer() | |
} | ||
|
||
/** | ||
* @phpstan-param array<string, array<string, mixed>> $adminGroups | ||
* @psalm-param array<string, Group> $adminGroups | ||
* | ||
* @return void | ||
*/ | ||
public function setAdminGroups(array $adminGroups) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the docs here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Psalm was failing and I'll check later today, but looks like this method does not work, even throws an error, I was going to check to deprecate it.
Based on this structure:
https://github.com/sonata-project/SonataAdminBundle/pull/6659/files#diff-96aac3a8c78cc9632a36cbb7489484b6c87ae336c1ceeaa028c4b265cafc6f38R41-R57
this method would try to to get and admin with id
label
,label_catalogue
,icon
, etc, that's why I guess it is not being used, but I haven't checked yet.