| Conditions | 5 |
| Paths | 5 |
| Total Lines | 31 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function handleElement() |
||
| 19 | { |
||
| 20 | $id = $this->owner->getRequest()->param('ID'); |
||
| 21 | |||
| 22 | if (!$id) { |
||
| 23 | user_error('No element ID supplied', E_USER_ERROR); |
||
| 24 | return false; |
||
| 25 | } |
||
| 26 | |||
| 27 | /** @var SiteTree $elementOwner */ |
||
| 28 | $elementOwner = $this->owner->data(); |
||
| 29 | |||
| 30 | $elementalAreaRelations = $this->owner->getElementalRelations(); |
||
| 31 | |||
| 32 | if (!$elementalAreaRelations) { |
||
| 33 | user_error(get_class($this->owner) . ' has no ElementalArea relationships', E_USER_ERROR); |
||
| 34 | return false; |
||
| 35 | } |
||
| 36 | |||
| 37 | foreach ($elementalAreaRelations as $elementalAreaRelation) { |
||
| 38 | $element = $elementOwner->$elementalAreaRelation()->Elements() |
||
| 39 | ->filter('ID', $id) |
||
| 40 | ->First(); |
||
| 41 | |||
| 42 | if ($element) { |
||
| 43 | return $element->getController(); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | user_error('Element $id not found for this page', E_USER_ERROR); |
||
| 48 | return false; |
||
| 49 | } |
||
| 51 |