Conditions | 6 |
Paths | 5 |
Total Lines | 16 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
34 | public function onPreWrite(ViewEvent $event): void |
||
35 | { |
||
36 | $request = $event->getRequest(); |
||
37 | $data = $request->attributes->get('data'); |
||
38 | if (!$data instanceof AbstractComponent || !$request->isMethod(Request::METHOD_DELETE)) { |
||
39 | return; |
||
40 | } |
||
41 | |||
42 | $positions = $data->getComponentPositions(); |
||
43 | $manager = $this->registry->getManagerForClass(ComponentPosition::class); |
||
44 | if (!$manager) { |
||
45 | return; |
||
46 | } |
||
47 | foreach ($positions as $position) { |
||
48 | if (!$position->pageDataProperty) { |
||
49 | $manager->remove($position); |
||
50 | } |
||
54 |