Conditions | 4 |
Paths | 5 |
Total Lines | 25 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
54 | public function beforeDelete(Event $event, EntityInterface $entity) |
||
55 | { |
||
56 | $field = $this->getConfig('field'); |
||
57 | |||
58 | if ($this->getTable()->hasField($field)) { |
||
59 | foreach ($this->getTable()->associations() as $association) { |
||
60 | $association->cascadeDelete($entity, [ |
||
61 | '_primary' => false, |
||
62 | ]); |
||
63 | } |
||
64 | |||
65 | $event->stopPropagation(); |
||
66 | |||
67 | if ($entity->isAccessible($field) === false) { |
||
68 | $entity->setAccess($field, true); |
||
69 | } |
||
70 | |||
71 | $entity = $this->getTable()->patchEntity($entity, [ |
||
72 | $field => Time::now(), |
||
73 | ]); |
||
74 | |||
75 | return $this->getTable()->save($entity); |
||
76 | } |
||
77 | |||
78 | return true; |
||
79 | } |
||
81 |