检查当前地址是否在指定的子分类中

@param array $category
@return bool
491715
protected function isInCategories(array $category)
    {
        $url = ltrim(wei()->request->getPathInfo(), '/');
        foreach ($category['navs'] as $i => $subCategories) {
            foreach ($subCategories['navs'] as $nav) {
                if ($nav['url'] == $url) {
                    return true;
                }
            }
        }

        return false;
    }
1129578
public function getComponentsWithCategory($category)
    {
        $components = array();
        foreach ($this->blockConfiguration as $blockComponent => $configuration) {
            if (isset($configuration['category']) && $category === $configuration['category']) {
                $components[] = $blockComponent;
            }
        }

        return $components;
    }
915896
public function destroy(Category $category)
    {
        $this->category->destroy($category);

        return redirect()->route('admin.product.category.index')
            ->withSuccess(trans('core::core.messages.resource deleted', ['name' => trans('product::categories.title.categories')]));
    }
146629
protected function prepareMetadata(array $category)
    {

        // initialize the metadata
        $metadata = array();

        // query whether or not, the passed category IS the root category
        if ($this->isRootCategory($category)) {
            return;
        }

        // if not, set the category ID in the metadata
        $metadata[UrlRewriteObserver::CATEGORY_ID] = (integer) $category[MemberNames::ENTITY_ID];

        // return the metadata
        return $metadata;
    }
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]);
    }
1359886
public function getPostsByCategory($category)
    {
        if (false === array_key_exists($category, $this->categoryIndex)) {
            return [];
        }

        $postNames = $this->categoryIndex[$category];

        return $this->getPostsByName($postNames);
    }
1052642
private static function _get_children_recursion($category) {

        $children_array = array();
        foreach ($category->children as $sortorder=>$child) {

            if (array_key_exists('itemtype', $child)) {
                $grade_item = new grade_item($child, false);

                if (in_array($grade_item->itemtype, array('course', 'category'))) {
                    $type  = $grade_item->itemtype.'item';
                    $depth = $category->depth;

                } else {
                    $type  = 'item';
                    $depth = $category->depth; // we use this to set the same colour
                }
                $children_array[$sortorder] = array('object'=>$grade_item, 'type'=>$type, 'depth'=>$depth);

            } else {
                $children = grade_category::_get_children_recursion($child);
                $grade_category = new grade_category($child, false);

                if (empty($children)) {
                    $children = array();
                }
                $children_array[$sortorder] = array('object'=>$grade_category, 'type'=>'category', 'depth'=>$grade_category->depth, 'children'=>$children);
            }
        }

        // sort the array
        ksort($children_array);

        return $children_array;
    }
1231209
public function getAll($category)
    {
        $ds = DIRECTORY_SEPARATOR;

        $category = str_replace('/', $ds, $category);

        $path = app_path().$ds.'lablog'.$ds.$category;

        $posts = $this->fs->files($path);

        $allPosts = array();

        foreach ($posts as $post) {
            if (strpos($post, '.post') === false) {
                continue;
            }
            $postPath = str_replace('.post', '', $post);
            $allPosts[$this->modified($post).rand()] = str_replace($path, '', $postPath);
        }

        krsort($allPosts);

        $posts = array();

        foreach ($allPosts as $post) {
            $categoryExplode = explode($ds, $post);
            $post = array_pop($categoryExplode);
            $posts[] = $this->getPost($category, $post);
        }

        return $posts;
    }
903594
public function setCategory(array $category)
    {
        $categoryClassInstance = new Category();
        foreach ($category as $categoryInstance) {
            Validate::isInstanceOf(
                $categoryInstance,
                $categoryClassInstance,
                'category'
            );
        }
        $this->category = $category;
    }
160841
public function inCategories(array $categories): self
    {
        foreach ($categories as $category) {
            if (is_array($category)) {
                $this->inCategory($category['category'], $category['domain']);
            } else {
                $this->inCategory($category);
            }
        }

        return $this;
    }
190747
public function getParents ($category)
		{
			if ($category instanceof $this->_modelClass)
			{
				$parents = [];
				foreach ($this->_data as $item)
					if ($category->lft > $item->lft and $category->rgt < $item->rgt)
						$parents[] = $item;

				return $parents;
			}

			return null;
		}
1276308
public function setCategory($category)
    {
        $allowedValues = $this->getCategoryAllowableValues();
        if (!in_array($category, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'category', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['category'] = $category;

        return $this;
    }
1058011
public function getChildren ($category)
		{
			$children = [];
			foreach ($this->_data as $item)
				if ($item->lft > $category->lft and $item->rgt < $category->rgt)
					$children[] = $item;

			return $children;
		}
883143
public function addCategory($category)
    {
        if (!($category instanceof Category)) {
            $category = new Category($category);
        }
        $this->categories[] = $category;
    }
351950
private function where($category, $and = '')
    {
        if (!empty($category)) {
            $sql = array();
            foreach ((array) $category as $like) {
                $sql[] = "c.category LIKE '{$like}%'";
            }
            $category = 'AND '.implode(' OR ', $sql);
        }

        return trim('INNER JOIN sitemap AS m INNER JOIN categories AS c WHERE s.docid = m.docid AND m.category_id = c.id '.$category.' '.$and);
    }
728324
public function descendantsOf(ChildCategory $category)
    {
        return $this
            ->addUsingAlias(ChildCategory::LEFT_COL, $category->getLeftValue(), Criteria::GREATER_THAN)
            ->addUsingAlias(ChildCategory::LEFT_COL, $category->getRightValue(), Criteria::LESS_THAN);
    }
870824
public function addChild(Category $category): Category
    {
        $this->children->add($category);

        if ($category->getParent() !== $this) {
            $category->setParent($this);
        }

        return $this;
    }