Skip to content

Commit ea41abb

Browse files
committed
Do not pass $name to Command::__construct() to allow lazy loading
1 parent 01870ea commit ea41abb

9 files changed

Lines changed: 11 additions & 26 deletions

File tree

src/Command/DebugTasksCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ class DebugTasksCommand extends Command
2929
private $taskExecutionRepository;
3030

3131
/**
32-
* @param string $name
3332
* @param TaskExecutionRepositoryInterface $taskExecutionRepository
3433
*/
35-
public function __construct($name, TaskExecutionRepositoryInterface $taskExecutionRepository)
34+
public function __construct(TaskExecutionRepositoryInterface $taskExecutionRepository)
3635
{
37-
parent::__construct($name);
36+
parent::__construct();
3837

3938
$this->taskExecutionRepository = $taskExecutionRepository;
4039
}

src/Command/ExecuteCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,15 @@ class ExecuteCommand extends Command
4545
private $eventDispatcher;
4646

4747
/**
48-
* @param string $name
4948
* @param TaskHandlerFactoryInterface $handlerFactory
5049
* @param TaskExecutionRepositoryInterface $executionRepository
5150
*/
5251
public function __construct(
53-
$name,
5452
TaskHandlerFactoryInterface $handlerFactory,
5553
TaskExecutionRepositoryInterface $executionRepository,
5654
EventDispatcherInterface $dispatcher
5755
) {
58-
parent::__construct($name);
56+
parent::__construct();
5957

6058
$this->handlerFactory = $handlerFactory;
6159
$this->executionRepository = $executionRepository;

src/Command/RunCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ class RunCommand extends Command
3333
private $scheduler;
3434

3535
/**
36-
* @param string $name
3736
* @param TaskRunnerInterface $runner
3837
* @param TaskSchedulerInterface $scheduler
3938
*/
40-
public function __construct($name, TaskRunnerInterface $runner, TaskSchedulerInterface $scheduler)
39+
public function __construct(TaskRunnerInterface $runner, TaskSchedulerInterface $scheduler)
4140
{
42-
parent::__construct($name);
41+
parent::__construct();
4342

4443
$this->runner = $runner;
4544
$this->scheduler = $scheduler;

src/Command/RunHandlerCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ class RunHandlerCommand extends Command
2828
private $handlerFactory;
2929

3030
/**
31-
* @param string $name
3231
* @param TaskHandlerFactoryInterface $handlerFactory
3332
*/
34-
public function __construct($name, TaskHandlerFactoryInterface $handlerFactory)
33+
public function __construct(TaskHandlerFactoryInterface $handlerFactory)
3534
{
36-
parent::__construct($name);
35+
parent::__construct();
3736

3837
$this->handlerFactory = $handlerFactory;
3938
}

src/Command/ScheduleSystemTasksCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,18 @@ class ScheduleSystemTasksCommand extends Command
4040
private $taskExecutionRepository;
4141

4242
/**
43-
* @param string $name
4443
* @param array $systemTasks
4544
* @param TaskSchedulerInterface $scheduler
4645
* @param SystemTaskRepositoryInterface $taskRepository
4746
* @param TaskExecutionRepositoryInterface $taskExecutionRepository
4847
*/
4948
public function __construct(
50-
$name,
5149
array $systemTasks,
5250
TaskSchedulerInterface $scheduler,
5351
SystemTaskRepositoryInterface $taskRepository,
5452
TaskExecutionRepositoryInterface $taskExecutionRepository
5553
) {
56-
parent::__construct($name);
54+
parent::__construct();
5755

5856
$this->systemTasks = $systemTasks;
5957
$this->scheduler = $scheduler;

src/Command/ScheduleTaskCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ class ScheduleTaskCommand extends Command
2929
private $scheduler;
3030

3131
/**
32-
* @param string $name
3332
* @param TaskSchedulerInterface $runner
3433
*/
35-
public function __construct($name, TaskSchedulerInterface $runner)
34+
public function __construct(TaskSchedulerInterface $runner)
3635
{
37-
parent::__construct($name);
36+
parent::__construct();
3837

3938
$this->scheduler = $runner;
4039
}

src/Resources/config/command.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
55
<services>
66
<service id="task.command.run" class="Task\TaskBundle\Command\RunCommand" public="true">
7-
<argument type="string">task:run</argument>
87
<argument type="service" id="task.runner"/>
98
<argument type="service" id="task.scheduler"/>
109
<!-- add entity_manager if doctrine storage is enabled -->
@@ -13,14 +12,12 @@
1312
</service>
1413

1514
<service id="task.command.run_handler" class="Task\TaskBundle\Command\RunHandlerCommand" public="true">
16-
<argument type="string">task:run:handler</argument>
1715
<argument type="service" id="task.handler.factory"/>
1816

1917
<tag name="console.command" command="task:run:handler"/>
2018
</service>
2119

2220
<service id="task.command.executor" class="Task\TaskBundle\Command\ExecuteCommand" public="true">
23-
<argument type="string">task:execute</argument>
2421
<argument type="service" id="task.handler.factory"/>
2522
<argument type="service" id="task.storage.task_execution"/>
2623
<argument type="service" id="event_dispatcher"/>
@@ -29,15 +26,13 @@
2926
</service>
3027

3128
<service id="task.command.schedule_task" class="Task\TaskBundle\Command\ScheduleTaskCommand" public="true">
32-
<argument type="string">task:schedule</argument>
3329
<argument type="service" id="task.scheduler"/>
3430
<!-- add entity_manager if doctrine storage is enabled -->
3531

3632
<tag name="console.command" command="task:schedule"/>
3733
</service>
3834

3935
<service id="task.command.debug_tasks" class="Task\TaskBundle\Command\DebugTasksCommand" public="true">
40-
<argument type="string">debug:tasks</argument>
4136
<argument type="service" id="task.storage.task_execution"/>
4237

4338
<tag name="console.command" command="debug:tasks"/>

src/Resources/config/storage/doctrine.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
<service id="task.storage.task_execution" alias="task.repository.task_execution" public="true"/>
1919

2020
<service id="task.command.schedule_system_tasks" class="Task\TaskBundle\Command\ScheduleSystemTasksCommand" public="true">
21-
<argument type="string">task:schedule:system-tasks</argument>
2221
<argument>%task.system_tasks%</argument>
2322
<argument type="service" id="task.scheduler"/>
2423
<argument type="service" id="task.repository.task"/>
2524
<argument type="service" id="task.storage.task_execution"/>
2625

27-
<tag name="console.command"/>
26+
<tag name="console.command" command="task:schedule:system-tasks"/>
2827
</service>
2928
</services>
3029
</container>

tests/Unit/Command/ScheduleSystemTasksCommandTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ protected function setUp(): void
5252
protected function createCommand(array $systemTasks)
5353
{
5454
return new ScheduleSystemTasksCommand(
55-
'task:schedule:system-tasks',
5655
$systemTasks,
5756
$this->scheduler->reveal(),
5857
$this->taskRepository->reveal(),

0 commit comments

Comments
 (0)