Skip to content

Added sorting options to ìbexa:debug:config` #631

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

adriendupuis
Copy link
Contributor

@adriendupuis adriendupuis commented Aug 8, 2025

🎫 Issue IBX-XXXXX

Description:

Sort parameter list when sortable, when it's an array of arrays by a scalar value's key.

For example, see admin siteaccess field templates by decreasing priority:
php bin/console ibexa:debug:config field_templates --siteaccess admin --sort priority --reverse-sort

For QA:

Documentation:

@adriendupuis adriendupuis force-pushed the enh-ibexa-debug-config branch from ea930f3 to 1aad6d2 Compare August 12, 2025 08:02
Copy link

@@ -95,6 +107,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$scope = $input->getOption('scope');
$parameterData = $this->configResolver->getParameter($parameter, $namespace, $scope);

if (null !== ($sort = $input->getOption('sort')) && is_array($parameterData) && is_array($parameterData[0]) && array_key_exists($sort, $parameterData[0]) && is_scalar($parameterData[0][$sort])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we somehow simplify this check ?

@@ -95,6 +107,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$scope = $input->getOption('scope');
$parameterData = $this->configResolver->getParameter($parameter, $namespace, $scope);

if (null !== ($sort = $input->getOption('sort')) && is_array($parameterData) && is_array($parameterData[0]) && array_key_exists($sort, $parameterData[0]) && is_scalar($parameterData[0][$sort])) {
if ($input->getOption('reverse-sort')) {
usort($parameterData, static function ($a, $b) use ($sort) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
usort($parameterData, static function ($a, $b) use ($sort) {
usort($parameterData, static function ($a, $b): int use ($sort) {

Could you also please specify types for $a and $b ?

return $b[$sort] <=> $a[$sort];
});
} else {
usort($parameterData, static function ($a, $b) use ($sort) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
usort($parameterData, static function ($a, $b) use ($sort) {
usort($parameterData, static function ($a, $b): int use ($sort) {

Could you also please specify types for $a and $b ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants