Return a mini-breadcrumb for a category

@param \Magento\Catalog\Model\Category $category The category

@return array
555036
private function getCategoryBreadcrumb(\Magento\Catalog\Model\Category $category)
    {
        $path    = $category->getPath();
        $rawPath = explode('/', $path);

        // First occurence is root category (1), second is root category of store.
        $rawPath = array_slice($rawPath, 2);

        // Last occurence is the category displayed.
        array_pop($rawPath);

        $breadcrumb = [];
        foreach ($rawPath as $categoryId) {
            $breadcrumb[] = html_entity_decode($this->getCategoryNameById($categoryId, $category->getStoreId()));
        }

        return $breadcrumb;
    }
199282
public function publish(Category $category)
    {
        $category->togglePublishedState();

        $category->getDescendants()->each(
            function (Category $cat) use ($category) {
                $cat->published = $category->published;
                $cat->save();
            }
        );

        $message = $category->published ? trans('cms::categories.publish.success') : trans('cms::categories.publish.error');

        return $this->notifySuccess($message);
    }
194012
private function categoriesHTML($category = null)
    {
        $categories = $this->eloqentCategory()->all();
        $total = $this->eloqent()->active()->count();

        $categoryId = 0;
        if ($category) {
            $categoryId = $category->id;
        }

        // get the relationship name - same as view
        $relationship = $this->view;
        $title = 'All <span>(' . $total . ')</span>';
        $html = '<li><a href="' . $this->URLPrefix . '" class="' . ($categoryId == 0 ? 'active' : '') . '">' . $title . '</a></li>';
        foreach ($categories as $k => $category) {

            // get total items for relationship / category
            $total = $category->{$relationship}()->count();

            if ($total > 0) {
                $active = $category->id == $categoryId ? 'active' : '';
                $title = $category->title . ' <span>(' . $total . ')</span>';
                $html .= '<li><a href="' . $this->URLPrefix . $category->url . '" class="' . $active . '">' . $title . ' </a></li>';
            }
        }

        return $html;
    }
526485
private function getCategory(Category $category, $delimiter = '')
    {
        $result = collect();
        $category->delimiter = $delimiter;
        $result->push($category);

        if (! $category->allChildrenTerm()->count()) {
            return $result;
        }

        foreach ($category->allChildrenTerm()->get() as $item) {
            $result = $result->merge($this->getCategory($item, $delimiter.'-'));
        }

        return $result;
    }
298024
public static function getAdapterForPostsCatgory($limit=5,$category='')
	{
		return static::find()->where('status="'.self::STATUS_PUBLISHED.'" AND categories_id = "'.$category.'"')
					->orderBy('created_at DESC')
					->limit($limit);
	}
590883
public function showAction(Category $category)
    {
        $deleteForm = $this->createDeleteForm($category);

        return array(
            'entity' => $category,
            'delete_form' => $deleteForm->createView(),
        );
    }
753699
private function getAttributes($category)
    {
        $collection = $this->attributeCollectionFactory->create(['category' => $category]);
        $collection
            ->setCategory($category)
            ->addIsFilterableFilter()
            ->addStoreLabel($category->getStoreId())
            ->setOrder('position', 'ASC')
            ->setOrder('attribute_id', 'ASC');

        $storeId = $this->getStoreId($category);

        if ($storeId && $category->getId()) {
            // Make a side effect on the context that will be used by the fulltext collection's request builder.
            $this->searchContext->setCurrentCategory($category)
                ->setStoreId($storeId);

            /** @var \Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\Collection $fulltextCollection */
            $fulltextCollection = $this->fulltextCollectionFactory->create();
            $fulltextCollection->setStoreId($storeId)
                ->addFieldToFilter('category_ids', $this->getCategoryFilterParam($category));

            $attributeSetIds = array_keys($fulltextCollection->getFacetedData('attribute_set_id'));
            if (!empty($attributeSetIds)) {
                $collection->setAttributeSetFilter($attributeSetIds);
            }
        }

        return $collection->getItems();
    }
1341387
def breadcrumbs(category_string, separator=' > ', using='categories.category'):
    
    cat = get_category(category_string, using)

    return {'category': cat, 'separator': separator}
703436
public function makeChildrenTree($categories)
    {
        $tmp = [];
        foreach ($categories as $key => $category){
            if(!key_exists('children', $category)) {
                $category->children = [];
            }

            // get children
            $children = $this->getChildren($category->categoryID);

            // call self to get a loop until every category has his children
            $category->children = $this->makeChildrenTree($children);

            $tmp[] = $category;
        }

        return Language::filterRows($tmp, false);
    }
384418
protected function _getCategoryBreadCrumb()
    {
        $paths = [];

        $categoryTree = $this->getCatTreePath();

        if ($categoryTree) {
            foreach ($categoryTree as $category) {
                /** @var \OxidEsales\Eshop\Application\Model\Category $category */
                $categoryPath = [];

                $categoryPath['link'] = $category->getLink();
                $categoryPath['title'] = $category->oxcategories__oxtitle->value;

                $paths[] = $categoryPath;
            }
        }

        return $paths;
    }
740029
public function getMessages($category, $language)
    {
        $key = $language . '/' . $category;
        if (!isset($this->_messages[$key])) {
            $this->_messages[$key] = $this->loadMessages($category, $language);
        }

        return $this->_messages[$key];
    }
802272
public function query(Category $category = null): array
    {
        if (! $category->exists) {
            $category->setRelation('term', [new Term()]);
        }

        return [
            'category' => $category,
            'catselect'=> $category->getAllCategories(),
        ];
    }
1305850
public static function adminCategoriesPrepareContent($category)
    {
        $actions = [];
        $actions[] = Html::button(Html::tag('span', '', ['class' => 'glyphicon glyphicon-eye-' . ($category->visible ? 'open' : 'close')]), ['class' => 'btn btn-xs text-muted', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => $category->visible ? Yii::t('podium/view', 'Category visible for guests') : Yii::t('podium/view', 'Category hidden for guests')]);
        $actions[] = Html::a(Html::tag('span', '', ['class' => 'glyphicon glyphicon-list']) . ' ' . Yii::t('podium/view', 'List Forums'), ['admin/forums', 'cid' => $category->id], ['class' => 'btn btn-default btn-xs']);
        $actions[] = Html::a(Html::tag('span', '', ['class' => 'glyphicon glyphicon-plus-sign']) . ' ' . Yii::t('podium/view', 'Create new forum'), ['admin/new-forum', 'cid' => $category->id], ['class' => 'btn btn-success btn-xs']);
        $actions[] = Html::a(Html::tag('span', '', ['class' => 'glyphicon glyphicon-cog']), ['admin/edit-category', 'id' => $category->id], ['class' => 'btn btn-default btn-xs', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('podium/view', 'Edit Category')]);
        $actions[] = Html::tag('span', Html::button(Html::tag('span', '', ['class' => 'glyphicon glyphicon-trash']), ['class' => 'btn btn-danger btn-xs', 'data-url' => Url::to(['admin/delete-category', 'id' => $category->id]), 'data-toggle' => 'modal', 'data-target' => '#podiumModalDelete']), ['data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('podium/view', 'Delete Category')]);

        return Html::tag('p', implode(' ', $actions), ['class' => 'pull-right']) . Html::tag('span', Html::encode($category->name), ['class' => 'podium-forum', 'data-id' => $category->id]);
    }
621989
private function getNewParentTree($category)
    {
        $pathIds = array_reverse(explode(',', $category->getPathInStore()));
        $pathIds[] = $category->getId();

        /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categories */
        $categories = $this->categoryCollectionFactory->create();

        return $categories->setStore($this->storeManager->getStore())
            ->addAttributeToSelect(['name', 'is_virtual_category', 'virtual_category_root'])
            ->addFieldToFilter('entity_id', ['in' => $pathIds]);
    }
417082
private function getCategoryFilterParam(\Magento\Catalog\Model\Category $category)
    {
        $filterParam = $category->getId();

        if ($category->getVirtualRule()) { // Implicit dependency to Virtual Categories module.
            $category->setIsActive(true);

            $filterParam = $category->getVirtualRule()->getCategorySearchQuery($category);
        }

        return $filterParam;
    }
86982
private function showList($category = null)
    {
        // eloquent model - VirtualTour::class
        $eloquent = $this->eloqent();

        // base builder
        $builder = $eloquent::with('category')->active();

        // if we need to filter by category
        if ($category && strlen($category) > 2) {

            $category = $this->eloqentCategory()->where('slug', $category)->first();

            if (!$category) {
                return redirect($this->URLPrefix);
            }

            // increment (dont increment on ajax pagination)
            if (!$this->request->ajax()) {

                // prefix the category in title
                $this->title = $category->title;

                // increment total views
                $category->increment('total_views');
                if ($category->getTable() == 'categories') {
                    $category->increment("views_" . $eloquent->getTable());
                }
            }

            // filter by category
            $builder->where('category_id', $category->id);
        }

        // order by date desc, paginate
        $items = $builder->orderBy('active_from', 'DESC')->paginate($this->paginate);

        // if ajax - paginate the articles
        if ($this->request->ajax()) {

            $view = "website.partials.content.pagination";
            if ($this->view == 'photographies') {
                $view = "website.partials.$this->view.pagination";
            }

            return response()->json(view()->make($view, compact('items'))->render());
        }

        $categories = $this->categoriesHTML($category);
        if ($category) {
            $this->addBreadcrumbLink($category->title, '/content/' . $category->url);
        }

        return $this->view("content.$this->view", compact('categories', 'items'));
    }
460096
protected static function loggerCategory($category): string
    {
        /** @noinspection PhpUndefinedFieldInspection */
        $prefix = static::$category ?? '';

        if (empty($category)) {
            return $prefix;
        }

        return ($prefix ? $prefix . ':' : '') . $category;
    }