* @package WoltLabSuite\Core\Data\Category * * @method Category getDecoratedObject() * @mixin Category */ class CategoryNode extends DatabaseObjectDecorator implements IObjectTreeNode { use TObjectTreeNode; /** * @inheritDoc */ protected static $baseClass = Category::class; /** * Returns true if this category is visible in a nested menu item list. * * @param AbstractDecoratedCategory $activeCategory * @return bool * @since 5.2 */ public function isVisibleInNestedList(?AbstractDecoratedCategory $activeCategory = null) { if (!$this->getParentCategory() || !$this->getParentCategory()->getParentCategory()) { // level 1 & 2 are always visible return true; } if ($activeCategory) { if ( $activeCategory->categoryID == $this->categoryID || $activeCategory->isParentCategory($this->getDecoratedObject()) ) { // is the active category or a parent of the active category return true; } if ($this->getParentCategory()->categoryID == $activeCategory->categoryID) { // is a direct child element of the active category return true; } } return false; } }