Skip to content

RFC: Added siteaccess option to application definition, instead of per command #635

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 2 commits into
base: main
Choose a base branch
from

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
Comment on lines +3 to +6
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
Copy link
Member

Choose a reason for hiding this comment

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

declare(strict_types=1); is missing

Copy link

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.

8 participants