Get categories from root to child

@param integer $categoryId Category ID

@since 2.3.0

@return array An array of \Thelia\Model\Category from root to wanted category
or an empty array if Category ID doesn't exists
763170
public static function getPathToCategory($categoryId)
    {
        $path = [];

        $category = (new CategoryQuery)->findPk($categoryId);
        if ($category !== null) {
            $path[] = $category;

            if ($category->getParent() !== 0) {
                $path = array_merge(self::getPathToCategory($category->getParent()), $path);
            }
        }

        return $path;
    }
764534
public static function getFolderTreeIds($folderId, $depth = 1)
    {
        $result = \is_array($folderId) ? $folderId : [ $folderId ];

        if ($depth > 1) {
            $folders = self::create()
                ->filterByParent($folderId, Criteria::IN)
                ->withColumn('id')
                ->find();

            foreach ($folders as $folder) {
                $result = array_merge(
                    $result,
                    self::getFolderTreeIds($folder->getId(), $depth - 1)
                );
            }
        }

        return $result;
    }
433447
protected function getProcessedCategoryIds()
    {
        $categoryIds = [];
        $source = $this->getSource();

        $source->rewind();
        while ($source->valid()) {
            $current = $source->current();
            if (isset($this->newCategory[$current[self::COL_ROOT]][$current[self::COL_CATEGORY]])) {
                $categoryIds[] = $this->newCategory[$current[self::COL_ROOT]][$current[self::COL_CATEGORY]];
            } elseif (isset($this->categoriesWithRoots[$current[self::COL_ROOT]][$current[self::COL_CATEGORY]])) {
                $categoryIds[] = $this->categoriesWithRoots[$current[self::COL_ROOT]][$current[self::COL_CATEGORY]];
            }

            $source->next();
        }

        return $categoryIds;
    }
1100361
private function loadCategoryNames($categoryIds, $storeId)
    {
        $loadCategoryIds = $categoryIds;

        if (isset($this->categoryNameCache[$storeId])) {
            $loadCategoryIds = array_diff($categoryIds, array_keys($this->categoryNameCache[$storeId]));
        }

        $loadCategoryIds  = array_map('intval', $loadCategoryIds);
        $useNameAttribute = $this->getUseNameInSearchAttribute();

        if (!empty($loadCategoryIds) && $useNameAttribute && $useNameAttribute->getId()) {
            $select = $this->prepareCategoryNameSelect($loadCategoryIds, $storeId);
            $entityIdField = $this->getEntityMetaData(CategoryInterface::class)->getIdentifierField();

            foreach ($this->getConnection()->fetchAll($select) as $row) {
                $categoryId = (int) $row[$entityIdField];
                $this->categoryNameCache[$storeId][$categoryId] = '';
                if ((bool) $row['use_name']) {
                    $this->categoryNameCache[$storeId][$categoryId] = $row['name'];
                }
            }
        }

        return isset($this->categoryNameCache[$storeId]) ? $this->categoryNameCache[$storeId] : [];
    }
132873
public static function getCategoryTreeIds($categoryId, $depth = 1)
    {
        $result = \is_array($categoryId) ? $categoryId : [ $categoryId ];

        if ($depth > 1) {
            $categories = self::create()
                ->filterByParent($categoryId, Criteria::IN)
                ->withColumn('id')
                ->find();

            foreach ($categories as $category) {
                $result = array_merge(
                    $result,
                    self::getCategoryTreeIds($category->getId(), $depth - 1)
                );
            }
        }

        return $result;
    }
1031627
private function getSlugParts(int $categoryId, string $locale): array
    {
        $category = $this->repo->getCategoriesPlain()->where('id', $categoryId)->first();
        $slugParts = [];

        if (!$category) {
            // Try to fetch from DB
            $category = Category::find($categoryId);

            if (!$category) {
                return [];
            }

            $category = [
                'id'        => $category->id,
                'parent_id' => $category->parent_id,
                'slugs'     => $category->translations->pluck('slug', 'locale')->toArray(),
            ];
        }

        $slugParts[] = array_get($category, 'slugs.' . $locale);

        if (isset($category['parent_id']) && $category['parent_id']) {
            $slugParts = array_merge($slugParts, $this->getSlugParts($category['parent_id'], $locale));
        }

        return $slugParts;
    }
635215
public function getAvailableParentCategoriesQueryBuilder($categoryId = null)
    {
        $queryBuilder = $this
            ->createQueryBuilder('c')
            ->where('c.root = 1');

        if (null !== $categoryId) {
            $queryBuilder
                ->andWhere('c.id <> :parent_category')
                ->setParameter('parent_category', $categoryId);
        }

        return $queryBuilder;
    }
377732
public function findEntitiesByCategoryId($categoryId, $locale)
    {
        $products = $this->productRepository->findByCategoryId($categoryId, $locale);

        return $products;
    }
482071
public function getChildrenCount($categoryId)
    {
        $select = $this->getConnection()->select()->from(
            $this->getEntityTable(),
            'children_count'
        )->where(
            'entity_id = :entity_id'
        );
        $bind = ['entity_id' => $categoryId];

        return $this->getConnection()->fetchOne($select, $bind);
    }
937045
public function getChildren($parentId)
    {
        return $this->channelList->filter(function (Channel $channel) use ($parentId) {
            return $channel->getParentId() == $parentId;
        });
    }
1214916
public function getAllCategoryTreesAsArray()
    {
        $rootIds = $this->getAllRootIds();

        $trees = array();
        foreach ($rootIds as $rootId) {
            $trees[$rootId] = $this->getCategoryTreeAsArray($rootId);
        }

        return $trees;
    }
738701
protected function getSolrRootlineForCategoryId($categoryId)
    {
        $categoryIdRootline = $this->buildCategoryIdRootline($categoryId);
        $solrRootline = $this->buildSolrHierarchyFromIdRootline($categoryIdRootline);

        return $solrRootline;
    }
610541
public function getEntityByCategory($root, $category)
    {
        if (isset($this->categoriesWithRoots[$root][$category])) {
            return $this->categoriesWithRoots[$root][$category];
        }

        if (isset($this->newCategory[$root][$category])) {
            return $this->newCategory[$root][$category];
        }

        return false;
    }
504663
public function getCategory(int $categoryId, int $siteId) : array
    {
        Assert::that($categoryId)->greaterThan(0, 'The $categoryId has to be positive');
        Assert::that($siteId)->greaterThan(0, 'The $siteId has to be positive');

        return (array)$this->master->doRequest(
            'GET',
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductService/{KEY}/Category/%d/%d', $categoryId, $siteId)
        );
    }
347139
public function childrenOf(ChildCategory $category)
    {
        return $this
            ->descendantsOf($category)
            ->addUsingAlias(ChildCategory::LEVEL_COL, $category->getLevel() + 1, Criteria::EQUAL);
    }
125041
public function get($categoryId, $params = array())
    {
        $resource = 'category/' . $categoryId . '.json';
        $resource .= '?' . $this->buildQueryString($params);
        $response = $this->getServiceResponse($resource);

        $getCategoryResponse = new Models\ResponseCategoryGet($response);

        return $getCategoryResponse->getCategory();
    }
1014224
public function getChildren($parentID)
    {
        $tmp = [];
        foreach($this->categoryList as $key => $item){
            if($item->parentID == $parentID) {
                $tmp[] = $item;
            }
        }

        return $tmp;
    }