@@ 403-416 (lines=14) @@ | ||
400 | * @param int $id |
|
401 | * @return bool |
|
402 | */ |
|
403 | public function isAncestor($id) |
|
404 | { |
|
405 | if ( ! is_null($this->parent)) { |
|
406 | if ($this->parent->id() == $id) { |
|
407 | return true; |
|
408 | } |
|
409 | ||
410 | return $this->parent->isAncestor($id); |
|
411 | } |
|
412 | ||
413 | return false; |
|
414 | } |
|
415 | ||
416 | /** |
|
417 | * Attempts to get an ancestor node by the given id. |
|
418 | * |
|
419 | * @param int $id |
|
@@ 422-435 (lines=14) @@ | ||
419 | * @param int $id |
|
420 | * @return null|AbstractNode |
|
421 | */ |
|
422 | public function getAncestor($id) |
|
423 | { |
|
424 | if ( ! is_null($this->parent)) { |
|
425 | if ($this->parent->id() == $id) { |
|
426 | return $this->parent; |
|
427 | } |
|
428 | ||
429 | return $this->parent->getAncestor($id); |
|
430 | } |
|
431 | ||
432 | return null; |
|
433 | } |
|
434 | ||
435 | /** |
|
436 | * Shortcut to return the first child. |
|
437 | * |
|
438 | * @return AbstractNode |