src/components/CategoryManager.php
public function getParent ($category, $depth = 1)
		{
			if ($category instanceof $this->_modelClass and $depth > 0)
			{
				if ($category->depth == $depth)
					return $category;
				foreach ($this->_data as $item)
					if ($category->lft > $item->lft and $category->rgt < $item->rgt and $item->depth == $depth)
						return $item;
			}

			return null;
		}
public function getParent ($category, $depth = 1)
		{
			if ($category instanceof $this->_modelClass and $depth > 0)
			{
				if ($category->depth == $depth)
					return $category;
				foreach ($this->_data as $item)
					if ($category->lft > $item->lft and $category->rgt < $item->rgt and $item->depth == $depth)
						return $item;
			}

			return null;
		}
public function getParent ( $ category , $ depth = 1 ) { if ( $ category instanceof $ this -> _modelClass and $ depth > 0 ) { if ( $ category -> depth == $ depth ) return $ category ; foreach ( $ this -> _data as $ item ) if ( $ category -> lft > $ item -> lft and $ category -> rgt < $ item -> rgt and $ item -> depth == $ depth ) return $ item ; } return null ; }
Finds category parent with given depth.
@param  Category $category
@param int       $depth
@return Category|null
Finds category parent with given depth .