| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Metricool\Interfaces; |
| 6 |
|
| 7 |
use Metricool\Features\TaskManagement\Exceptions\DismissRequiredTaskException; |
| 8 |
|
| 9 |
interface TaskInterface |
| 10 |
{ |
| 11 |
/** |
| 12 |
* Returns the unique identifier of the task |
| 13 |
*/ |
| 14 |
public function getId(): string; |
| 15 |
|
| 16 |
/** |
| 17 |
* Returns the status of the task. For all available statuses |
| 18 |
* {@see AbstractTask} constants. |
| 19 |
*/ |
| 20 |
public function getStatus(): string; |
| 21 |
|
| 22 |
|
| 23 |
/** |
| 24 |
* Returns the priority of the task. A lower number is more important. |
| 25 |
*/ |
| 26 |
public function getPriority(): int; |
| 27 |
|
| 28 |
/** |
| 29 |
* Returns the version of the task |
| 30 |
*/ |
| 31 |
public function getVersion(): string; |
| 32 |
|
| 33 |
/** |
| 34 |
* Returns whether the task should be reactivated when the task is upgraded. |
| 35 |
* This is useful for tasks that are dismissed by the user but should be |
| 36 |
* reactivated when the task is upgraded to a new version. |
| 37 |
*/ |
| 38 |
public function isReactivateOnUpgrade(): bool; |
| 39 |
|
| 40 |
/** |
| 41 |
* Method is used to add an action to the UI of the task item. |
| 42 |
* @example |
| 43 |
* [ |
| 44 |
* 'type' => 'button', |
| 45 |
* 'text' => 'Button text', |
| 46 |
* 'link' => 'https://example.com' | '/services/new, |
| 47 |
* ] |
| 48 |
* @return array |
| 49 |
*/ |
| 50 |
public function getAction(): array; |
| 51 |
|
| 52 |
/** |
| 53 |
* Returns all data needed to show the task in the UI. Keys that are |
| 54 |
* required are 'id', 'text', 'status', 'type' and 'action'. |
| 55 |
*/ |
| 56 |
public function toArray(): array; |
| 57 |
|
| 58 |
/** |
| 59 |
* Reads if the task is required |
| 60 |
*/ |
| 61 |
public function isRequired(): bool; |
| 62 |
|
| 63 |
/** |
| 64 |
* Reads if the task is hidden |
| 65 |
*/ |
| 66 |
public function isHidden(): bool; |
| 67 |
|
| 68 |
/** |
| 69 |
* Sets the status of the task from another task. |
| 70 |
*/ |
| 71 |
public function setStatusFromTask(TaskInterface $task): self; |
| 72 |
|
| 73 |
/** |
| 74 |
* Activate the task by setting the state to 'open' |
| 75 |
*/ |
| 76 |
public function open(): self; |
| 77 |
|
| 78 |
/** |
| 79 |
* Set the task to the 'urgent' state |
| 80 |
*/ |
| 81 |
public function urgent(): self; |
| 82 |
|
| 83 |
/** |
| 84 |
* Dismiss the task by setting the state to 'dismissed' |
| 85 |
* @throws DismissRequiredTaskException if the task is required |
| 86 |
*/ |
| 87 |
public function dismiss(): self; |
| 88 |
|
| 89 |
/** |
| 90 |
* Complete the task by setting the state to 'completed' |
| 91 |
*/ |
| 92 |
public function complete(): self; |
| 93 |
|
| 94 |
/** |
| 95 |
* Hide the task by setting the state to 'hidden' |
| 96 |
*/ |
| 97 |
public function hide(): self; |
| 98 |
} |
| 99 |
|