Skip to content

Commit f38a848

Browse files
added command and fixed task persisting
1 parent 61fd1b7 commit f38a848

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/Command/DebugTasksCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Symfony\Component\Console\Command\Command;
66
use Symfony\Component\Console\Helper\Table;
77
use Symfony\Component\Console\Input\InputInterface;
8+
use Symfony\Component\Console\Input\InputOption;
89
use Symfony\Component\Console\Output\OutputInterface;
910
use Task\Storage\StorageInterface;
1011

@@ -33,8 +34,8 @@ public function __construct($name, StorageInterface $storage)
3334
protected function configure()
3435
{
3536
$this->setDescription('Debug tasks')
36-
->addOption('limit', 'l')
37-
->addOption('key');
37+
->addOption('limit', 'l', InputOption::VALUE_REQUIRED, '', null)
38+
->addOption('key', 'k', InputOption::VALUE_REQUIRED, '', null);
3839
}
3940

4041
/**
@@ -57,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5758
foreach ($tasks as $task) {
5859
$start = null;
5960
$duration = null;
60-
if (null !== $task->getLastExecution()) {
61+
if ($task->getLastExecution()) {
6162
$start = $task->getLastExecution()->getFinishedAtAsDateTime()->format(\DateTime::RFC3339);
6263
$duration = $task->getLastExecution()->getExecutionDuration();
6364
}

src/Resources/config/command.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,12 @@
2323

2424
<tag name="console.command"/>
2525
</service>
26+
27+
<service id="task.command.debug_tasks" class="Task\TaskBundle\Command\DebugTasksCommand">
28+
<argument type="string">debug:tasks</argument>
29+
<argument type="service" id="task.storage"/>
30+
31+
<tag name="console.command"/>
32+
</service>
2633
</services>
2734
</container>

src/Storage/DoctrineStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function clear()
116116

117117
private function setTask(TaskEntity $entity, TaskInterface $task)
118118
{
119-
$entity->setTask($task);
119+
$entity->setTask(clone $task);
120120
$entity->setUuid($task->getUuid());
121121
$entity->setKey($task->getKey());
122122
$entity->setCompleted($task->isCompleted());

0 commit comments

Comments
 (0)