Skip to content

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 ?

@adriendupuis adriendupuis marked this pull request as draft August 20, 2025 11:53
@adriendupuis adriendupuis changed the title Added sorting options to ìbexa:debug:config` Added sorting options to ibexa:debug:config Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants