Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

49 changes: 49 additions & 0 deletions src/bundle/Core/EventListener/ApplicationCommandListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

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.


use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

final class ApplicationCommandListener implements EventSubscriberInterface
{
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.

['onConsoleCommand', 256],
],
];
}

public function onConsoleCommand(ConsoleCommandEvent $event): void
{
$command = $event->getCommand();
if ($command === null) {
return;
}

$application = $command->getApplication();
if ($application === null) {
return;
}

$inputDefinition = $application->getDefinition();
if (false === $inputDefinition->hasOption('siteaccess')) {
$inputDefinition->addOption(new InputOption(
'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',

));
}
}
}
2 changes: 0 additions & 2 deletions src/bundle/Core/IbexaCoreBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Ibexa\Bundle\Core\DependencyInjection\Compiler\ChainConfigResolverPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\ChainRoutingPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\ConsoleCacheWarmupPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\ConsoleCommandPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\EntityManagerFactoryServiceLocatorPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\FieldTypeParameterProviderRegistryPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\FragmentPass;
Expand Down Expand Up @@ -81,7 +80,6 @@ public function build(ContainerBuilder $container): void
$container->addCompilerPass(new NotificationRendererPass());
$container->addCompilerPass(new ConsoleCacheWarmupPass());
$container->addCompilerPass(new SiteAccessMatcherRegistryPass());
$container->addCompilerPass(new ConsoleCommandPass());
$container->addCompilerPass(new LazyDoctrineRepositoriesPass(), PassConfig::TYPE_BEFORE_REMOVING);
$container->addCompilerPass(new EntityManagerFactoryServiceLocatorPass());
$container->addCompilerPass(new InjectEntityManagerMappingsPass());
Expand Down
4 changes: 4 additions & 0 deletions src/bundle/Core/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ services:
Ibexa\Bundle\Core\DependencyInjection\Configuration\ComplexSettings\ComplexSettingValueResolver:
class: Ibexa\Bundle\Core\DependencyInjection\Configuration\ComplexSettings\ComplexSettingValueResolver

Ibexa\Bundle\Core\EventListener\ApplicationCommandListener:
tags:
- { name: kernel.event_subscriber }

Ibexa\Bundle\Core\EventListener\ConsoleCommandListener:
class: Ibexa\Bundle\Core\EventListener\ConsoleCommandListener
arguments:
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions tests/integration/Core/LegacyTestContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Ibexa\Tests\Integration\Core;

use Ibexa\Bundle\Core\DependencyInjection\Compiler\ConsoleCommandPass;
use Ibexa\Bundle\Core\SiteAccess\Config\ComplexConfigProcessor;
use Ibexa\Contracts\Core\SiteAccess\ConfigProcessor;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
Expand Down Expand Up @@ -128,8 +127,6 @@ private function registerCompilerPasses(): void
$this->addCompilerPass(new Compiler\Search\Legacy\CriterionFieldValueHandlerRegistryPass());
$this->addCompilerPass(new Compiler\Search\Legacy\SortClauseConverterPass());

$this->addCompilerPass(new ConsoleCommandPass());

// Symfony 4 makes services private by default. Test cases are not prepared for this.
// This is a simple workaround to override services as public.
$this->addCompilerPass(new SetAllServicesPublicPass());
Expand Down
Loading