Conditions | 9 |
Paths | 20 |
Total Lines | 40 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
34 | public function handleWidget() |
||
35 | { |
||
36 | $SQL_id = $this->owner->getRequest()->param('ID'); |
||
37 | if (!$SQL_id) { |
||
38 | return false; |
||
39 | } |
||
40 | |||
41 | // find WidgetArea relations |
||
42 | $widgetAreaRelations = array(); |
||
43 | $hasOnes = $this->owner->data()->hasOne(); |
||
44 | |||
45 | if (!$hasOnes) { |
||
46 | return false; |
||
47 | } |
||
48 | |||
49 | foreach ($hasOnes as $hasOneName => $hasOneClass) { |
||
50 | if ($hasOneClass == WidgetArea::class || is_subclass_of($hasOneClass, WidgetArea::class)) { |
||
51 | $widgetAreaRelations[] = $hasOneName; |
||
52 | } |
||
53 | } |
||
54 | |||
55 | // find widget |
||
56 | $widget = null; |
||
57 | |||
58 | foreach ($widgetAreaRelations as $widgetAreaRelation) { |
||
59 | if ($widget) { |
||
60 | break; |
||
61 | } |
||
62 | |||
63 | $widget = $this->owner->data()->$widgetAreaRelation()->Widgets() |
||
64 | ->filter('ID', $SQL_id) |
||
65 | ->First(); |
||
66 | } |
||
67 | |||
68 | if (!$widget) { |
||
69 | user_error('No widget found', E_USER_ERROR); |
||
70 | } |
||
71 | |||
72 | return $widget->getController(); |
||
73 | } |
||
74 | } |
||
75 |
This check marks private properties in classes that are never used. Those properties can be removed.