Skip to content

Commit 9da654e

Browse files
committed
Pass null to Command::__construct() to allow lazy loading
Passing a string means Symfony cannot lazily load the commands.
1 parent 01870ea commit 9da654e

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/Resources/config/command.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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>
7+
<argument>null</argument>
88
<argument type="service" id="task.runner"/>
99
<argument type="service" id="task.scheduler"/>
1010
<!-- add entity_manager if doctrine storage is enabled -->
@@ -13,14 +13,14 @@
1313
</service>
1414

1515
<service id="task.command.run_handler" class="Task\TaskBundle\Command\RunHandlerCommand" public="true">
16-
<argument type="string">task:run:handler</argument>
16+
<argument>null</argument>
1717
<argument type="service" id="task.handler.factory"/>
1818

1919
<tag name="console.command" command="task:run:handler"/>
2020
</service>
2121

2222
<service id="task.command.executor" class="Task\TaskBundle\Command\ExecuteCommand" public="true">
23-
<argument type="string">task:execute</argument>
23+
<argument>null</argument>
2424
<argument type="service" id="task.handler.factory"/>
2525
<argument type="service" id="task.storage.task_execution"/>
2626
<argument type="service" id="event_dispatcher"/>
@@ -29,15 +29,15 @@
2929
</service>
3030

3131
<service id="task.command.schedule_task" class="Task\TaskBundle\Command\ScheduleTaskCommand" public="true">
32-
<argument type="string">task:schedule</argument>
32+
<argument>null</argument>
3333
<argument type="service" id="task.scheduler"/>
3434
<!-- add entity_manager if doctrine storage is enabled -->
3535

3636
<tag name="console.command" command="task:schedule"/>
3737
</service>
3838

3939
<service id="task.command.debug_tasks" class="Task\TaskBundle\Command\DebugTasksCommand" public="true">
40-
<argument type="string">debug:tasks</argument>
40+
<argument>null</argument>
4141
<argument type="service" id="task.storage.task_execution"/>
4242

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

src/Resources/config/storage/doctrine.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
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>
21+
<argument>null</argument>
2222
<argument>%task.system_tasks%</argument>
2323
<argument type="service" id="task.scheduler"/>
2424
<argument type="service" id="task.repository.task"/>
2525
<argument type="service" id="task.storage.task_execution"/>
2626

27-
<tag name="console.command"/>
27+
<tag name="console.command" command="task:schedule:system-tasks"/>
2828
</service>
2929
</services>
3030
</container>

tests/Unit/Command/ScheduleSystemTasksCommandTest.php

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

0 commit comments

Comments
 (0)