@param mixed  $toMarshal
@param string $category

@return mixed

@throws NotSupportedException If the given $toMarshal isn't supported by any registered strategies

@api
773320
public function marshal($toMarshal, $category = null)
    {
        if (!$this->isSorted) {
            $this->sortStrategies();
        }
        foreach ($this->prioritizedStrategies as $priority => $strategies) {
            foreach ($strategies as $strategy) {
                if ($strategy->supports($toMarshal, $category)) {
                    return $strategy->marshal($toMarshal);
                }
            }
        }

        throw new NotSupportedException('The given $toMarshal is not supported by any registered strategies.');
    }
176182
public function addCategory(CategoryInterface $category)
    {
        if (!$this
            ->categories
            ->contains($category)
        ) {
            $this
                ->categories
                ->add($category);
        }

        return $this;
    }
1050335
public function hasParentCategory($category): bool
    {
        if ($category instanceof CategoryInterface) {
            $category = $category->getExternalId();
        }

        return $this->parentCategories->exists(function ($key, CategoryInterface $element) use ($category) {
            return $element->getExternalId() === $category;
        });
    }
998877
public function update(CategoryRequest $request, Category $category)
    {
        try {
            $attributes = $request->all();

            $category->update($attributes);
            return $this->response->message(trans('messages.success.updated', ['Module' => trans('faq::category.name')]))
                ->code(204)
                ->status('success')
                ->url(guard_url('faq/category/' . $category->getRouteKey()))
                ->redirect();
        } catch (Exception $e) {
            return $this->response->message($e->getMessage())
                ->code(400)
                ->status('error')
                ->url(guard_url('faq/category/' . $category->getRouteKey()))
                ->redirect();
        }

    }
1130050
public function getAchievementsByCategory(Category $category)
    {
        $achievements = array();

        /** @var Achievement $achievement */
        foreach ($this->getAchievements() as $achievement) {
            if ($achievement->getCategory() == $category) {
                $achievements[] = $achievement;
            }
        }

        return $achievements;
    }
368617
public function setAllowedCategories($categories)
    {
        if (is_string($categories)) {
            $categories = preg_split('/\s*,\s*/', $categories);
        }
        $this->allowedCategories = (array)$categories;
        return $this;
    }
945092
protected function getModuleByTransCategory($category)
    {
        foreach(TranslationsBuilder::$transCatToModule as $pattern => $module) {
            if (0 === strpos($category, rtrim($pattern, '*'))) {
                return $module;
            }
        }
    }
898028
private function findOrCreateCategoryTranslation(
        CategoryInterface $category,
        CategoryWrapper $categoryWrapper,
        $locale
    ) {
        $translationEntity = $category->findTranslationByLocale($locale);
        if (!$translationEntity) {
            $translationEntity = $this->categoryTranslationRepository->createNew();
            $translationEntity->setLocale($locale);
            $categoryWrapper->setTranslation($translationEntity);
        }

        return $translationEntity;
    }
1369526
public function category($category = null)
  {
    if (null === $category)
    {
      return isset($this->requestConfig['category']) ? $this->requestConfig['category'] : null;
    }

    $this->requestConfig['category'] = $category;

    return $this;
  }
44785
public function actionGetCategoryUrls(string $category, array $criteria = [], $siteId = null): Response
    {
        return $this->asJson(RouteMap::$plugin->routes->getCategoryUrls($category, $criteria, $siteId));
    }
868887
public static function create_from_category($category) {
        $event = self::create(array(
            'objectid' => $category->id,
            'context' => \context_system::instance(),
            'other' => array(
                'name' => $category->name,
            )
        ));

        $event->add_record_snapshot('user_info_category', $category);

        return $event;
    }
1241549
public function add($category)
    {
        if (is_array($category)) {
            $this->collection[] = new Category($category);
        } elseif (is_object($category) && $category instanceof Category) {
            $this->collection[] = $category;
        }

        return $this;
    }
665491
public function sortAction(Request $request, $categoryId)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Category $category */
        $category = $em->getRepository('EcommerceBundle:Category')->find($categoryId);

        if (!$category) {
            throw $this->createNotFoundException('Unable to find Category entity.');
        }

        if ($request->isXmlHttpRequest()) {
            $this->get('admin_manager')->sort('EcommerceBundle:Feature', $request->get('values'));

            return new Response(0, 200);
        }

        $features = $em->getRepository('EcommerceBundle:Feature')->findBy(
            array('category' => $category),
            array('order' => 'asc')
        );

        return array(
            'features' => $features,
            'category' => $category
        );
    }
256876
private function unserializeProductPositions(\Magento\Catalog\Model\Category $category)
    {
        $productPositions = $category->getSortedProducts() ? $category->getSortedProducts() : [];

        if (is_string($productPositions)) {
            try {
                $productPositions = $this->jsonHelper->jsonDecode($productPositions);
            } catch (\Exception $e) {
                $productPositions = [];
            }
        }

        $category->setSortedProducts($productPositions);

        return $this;
    }
868462
public function addCategoryToCrawlerQueue($category) {
        $catUrls = array();
        $origStore = Mage::app()->getStore();
        foreach (Mage::app()->getStores() as $storeId => $store) {
            Mage::app()->setCurrentStore($store);
            $catUrls[] = $category->getUrl();
        }
        Mage::app()->setCurrentStore($origStore);
        return $this->addUrlsToCrawlerQueue($catUrls);
    }
1061974
public static function getInstance($category = self::CATEGORY_DEFAULT)
    {
        if (!isset(self::$instances[$category])) {
            self::$instances[$category] = new static($category);
        }
        return self::$instances[$category];
    }
1225907
public function setCategory($category, $preserveDefault = false, $includeSubcategories = false)
    {
        /** @var Model $model */
        $model = $this->framework->getAdapter(Model::class);

        // Include the subcategories
        if ($includeSubcategories) {
            /** @var NewsCategoryModel $newsCategoryModel */
            $newsCategoryModel = $this->framework->getAdapter(NewsCategoryModel::class);
            $category = $newsCategoryModel->getAllSubcategoriesIds($category);
        }

        $newsIds = $model->getReferenceValues('tl_news', 'categories', $category);
        $newsIds = $this->parseIds($newsIds);

        if (0 === \count($newsIds)) {
            throw new NoNewsException();
        }

        // Do not preserve the default categories
        if (!$preserveDefault) {
            unset($this->columns['defaultCategories']);
        }

        $t = $this->getNewsModelAdapter()->getTable();

        $this->columns[] = "$t.id IN(".\implode(',', $newsIds).')';
    }