Skip to content

Conversation

Steveb-p
Copy link
Contributor

🎫 Issue IBX-10428

Description:

This is a follow-up PR for #634 that contains a different solution, which changes how the siteaccess option is added.

This ensures that invokable commands also receive --siteaccess as an option, without the need to add

#[Option('siteaccess')
?string $siteaccess = null

to command explicitly.

For QA:

Documentation:

@Steveb-p Steveb-p force-pushed the rfc/register-option-siteaccess-on-application branch from 414402a to ccf7d2b Compare August 13, 2025 12:49
@Steveb-p Steveb-p requested a review from Copilot August 13, 2025 12:56
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors how the siteaccess option is added to console commands by moving from a compiler pass approach to an application-level event listener. Instead of adding the option to individual command definitions during container compilation, the new approach adds the option to the application's input definition when any command is executed.

Key changes:

  • Replaces per-command option injection with application-level option registration
  • Ensures invokable commands receive the --siteaccess option without explicit configuration
  • Removes the need for manual option declaration in command classes

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/bundle/Core/EventListener/ApplicationCommandListener.php New event listener that adds siteaccess option to application definition on command execution
src/bundle/Core/Resources/config/services.yml Registers the new ApplicationCommandListener as an event subscriber
src/bundle/Core/IbexaCoreBundle.php Removes the ConsoleCommandPass compiler pass registration
src/bundle/Core/DependencyInjection/Compiler/ConsoleCommandPass.php Removes the compiler pass that added siteaccess option to individual commands
tests/bundle/Core/DependencyInjection/Compiler/ConsoleCommandPassTest.php Removes tests for the deleted compiler pass

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

* @license For full copyright and license information view LICENSE file distributed with this source code.
*/

namespace Ibexa\Bundle\Core\EventListener;
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

The class is missing a docblock that explains its purpose. Consider adding a class-level docblock to describe that this listener adds the siteaccess option to the application's input definition for all console commands.

Copilot uses AI. Check for mistakes.

public static function getSubscribedEvents(): array
{
return [
ConsoleEvents::COMMAND => [
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

The magic number 256 for the event priority lacks explanation. Consider adding a comment explaining why this specific priority is chosen, especially since it's quite high and suggests it needs to run before other listeners.

Suggested change
ConsoleEvents::COMMAND => [
ConsoleEvents::COMMAND => [
// Use a high priority (256) to ensure this listener runs before other listeners,
// so that the 'siteaccess' option is available as early as possible.

Copilot uses AI. Check for mistakes.

@Steveb-p Steveb-p requested a review from a team August 14, 2025 08:26
@ezrobot ezrobot requested review from adamwojs, mikadamczyk, alongosz, ciastektk, ViniTou, barw4, wiewiurdp, konradoboza and tbialcz and removed request for a team August 14, 2025 08:26
Base automatically changed from ibx-10428/handle-invokable-commands to main August 14, 2025 13:18
@Steveb-p Steveb-p force-pushed the rfc/register-option-siteaccess-on-application branch from 476f328 to 685bf2f Compare August 14, 2025 13:21
@adamwojs adamwojs changed the title RFC: Added siteaccess option to application definition, instead of per command IBX-10428: Added siteaccess option to application definition, instead of per command Aug 19, 2025
@adamwojs adamwojs added Ready for QA Doc needed The changes require some documentation labels Aug 19, 2025
@tomaszszopinski tomaszszopinski self-assigned this Aug 25, 2025
@tomaszszopinski tomaszszopinski force-pushed the rfc/register-option-siteaccess-on-application branch from b002110 to 239feea Compare August 25, 2025 09:02
Copy link

Copy link

@tomaszszopinski tomaszszopinski left a comment

Choose a reason for hiding this comment

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

QA approved - DXP 5.0 commerce.

Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

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

It seems old test coverage was removed, but does it work OOTB or we're just missing the functional coverage testing if siteaccess option was indeed added?

'siteaccess',
null,
InputOption::VALUE_OPTIONAL,
'SiteAccess to use for operations. If not provided, default siteaccess will be used',
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
'SiteAccess to use for operations. If not provided, default siteaccess will be used',
'SiteAccess to use for operations. If not provided, default SiteAccess will be used',

@adamwojs adamwojs merged commit 5eb3e83 into main Aug 25, 2025
15 checks passed
@adamwojs adamwojs deleted the rfc/register-option-siteaccess-on-application branch August 25, 2025 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Doc needed The changes require some documentation QA approved Ready for QA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants