Total Complexity | 5 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | trait HasDraftedFlagHelpers |
||
17 | { |
||
18 | public function initializeHasDraftedFlagHelpers(): void |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * If entity is drafted. |
||
25 | * |
||
26 | * @return bool |
||
27 | */ |
||
28 | public function isDrafted(): bool |
||
29 | { |
||
30 | return $this->getAttributeValue('is_drafted'); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * If entity is opened. |
||
35 | * |
||
36 | * @return bool |
||
37 | */ |
||
38 | public function isUndrafted(): bool |
||
39 | { |
||
40 | return !$this->isDrafted(); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Mark entity as drafted. |
||
45 | * |
||
46 | * @return void |
||
47 | */ |
||
48 | public function draft(): void |
||
49 | { |
||
50 | $this->setAttribute('is_drafted', true); |
||
51 | $this->save(); |
||
52 | |||
53 | $this->fireModelEvent('drafted', false); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Mark entity as opened. |
||
58 | * |
||
59 | * @return void |
||
60 | */ |
||
61 | public function undraft(): void |
||
67 | } |
||
68 | } |
||
69 |