| 1 | <?php |
||
| 8 | abstract class HierarchicalTerm extends BaseTerm |
||
| 9 | { |
||
| 10 | protected function detectLoop($parent, $child) |
||
| 11 | { |
||
| 12 | if ($parent === $child) { |
||
| 13 | return true; |
||
| 14 | } |
||
| 15 | |||
| 16 | foreach ($this->getChildren($child) as $grandChild) { |
||
| 17 | if ($this->detectLoop($parent, $grandChild)) { |
||
| 18 | return true; |
||
| 19 | } |
||
| 20 | } |
||
| 21 | |||
| 22 | return false; |
||
| 23 | } |
||
| 24 | |||
| 25 | abstract public function getParent($term); |
||
| 27 | |||
| 28 | abstract public function getChildren($term); |
||
| 30 | } |
||
| 31 |