-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStepModel.php
More file actions
75 lines (65 loc) · 1.44 KB
/
StepModel.php
File metadata and controls
75 lines (65 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace App\Model;
use App\Entity\Step;
use App\Model\Interface\Configurable;
use App\Model\Interface\Exportable;
use App\Model\Interface\Persistable;
use App\Model\Trait\Conditionals;
use App\Model\Trait\Config;
use App\Model\Trait\Entity;
use App\Model\TaskModel;
use App\Model\Trait\Ref;
use App\Model\Trait\Relations;
use App\Service\Tasks;
/**
* @method int getId()
* @method setId( int $id )
* @method string getName()
* @method setName( string $name )
* @method string getDescription()
* @method setDescription( string $description )
*/
class StepModel implements Exportable, Configurable, Persistable
{
use Entity;
use Ref;
use Config;
use Relations;
use Conditionals;
public function __construct( Step $step )
{
$this->entity = $step;
$this->config = $step->getConfig();
}
public function getTasks(): array
{
$tasks = [];
foreach ( $this->getConfig( 'tasks' ) ?? [] as $task ) {
$tasks[] = Tasks::getTask( $task['_class'] ?? '' );
}
return $tasks;
}
public function getTask( $ref ): TaskModel|null
{
foreach ( $this->getConfig( 'tasks' ) ?? [] as $task ) {
if ( $task['_ref'] === $ref ) {
return Tasks::getTask( $task['_class'] ?? '' );
}
}
return null;
}
public static function getFields(): array
{
// @todo Implement fields.
return [
'tasks' => [
'label' => 'Tasks',
'type' => 'tasks',
],
];
}
public static function getEntityClass(): string
{
return Step::class;
}
}