private static function findAllAncestry($categoryId, $parentCategoriesArray = [])
    {
        $category = Category::findOne($categoryId);
        if (!empty($category)) {
            $parentCategoryId = $category->parent_id;
        }
        else throw new NotFoundHttpException();

        if (!empty($parentCategoryId)) {
            $parentCategoriesArray[] = $parentCategoryId;
            return self::findAllAncestry($parentCategoryId, $parentCategoriesArray);
        } else return $parentCategoriesArray;
    }
private static function findAllAncestry($categoryId, $parentCategoriesArray = [])
    {
        $category = Category::findOne($categoryId);
        if (!empty($category)) {
            $parentCategoryId = $category->parent_id;
        }
        else throw new NotFoundHttpException();

        if (!empty($parentCategoryId)) {
            $parentCategoriesArray[] = $parentCategoryId;
            return self::findAllAncestry($parentCategoryId, $parentCategoriesArray);
        } else return $parentCategoriesArray;
    }
private static function findAllAncestry ( $ categoryId , $ parentCategoriesArray = [ ] ) { $ category = Category :: findOne ( $ categoryId ) ; if ( ! empty ( $ category ) ) { $ parentCategoryId = $ category -> parent_id ; } else throw new NotFoundHttpException ( ) ; if ( ! empty ( $ parentCategoryId ) ) { $ parentCategoriesArray [ ] = $ parentCategoryId ; return self :: findAllAncestry ( $ parentCategoryId , $ parentCategoriesArray ) ; } else return $ parentCategoriesArray ; }
Gets all category's ancestry.
@param $categoryId
@param array $parentCategoriesArray
@return array
@throws NotFoundHttpException
Gets all category s ancestry .