murph-skeleton/core/Event/Task/TaskInitEvent.php

38 lines
727 B
PHP
Raw Normal View History

2021-05-24 18:41:57 +02:00
<?php
namespace App\Core\Event\Task;
use Symfony\Contracts\EventDispatcher\Event;
/**
* class TaskInitEvent.
*
* @author Simon Vieille <simon@deblan.fr>
*/
class TaskInitEvent extends Event
{
const INIT_EVENT = 'task_event.init';
protected array $tasks = [];
public function getTasks(): array
{
2021-05-24 18:42:44 +02:00
usort($this->tasks, function ($t1, $t2) {
return $t1['section'] != $t2['section'];
2021-05-24 18:41:57 +02:00
});
return $this->tasks;
}
2021-05-30 17:56:45 +02:00
public function addTask(string $task, string $section, string $label): self
2021-05-24 18:41:57 +02:00
{
$this->tasks[$task] = [
'label' => $label,
'section' => $section,
'task' => $task,
];
return $this;
}
}