Returns the children for a given category.
public findChildren ( integer $key, string | null $sortBy = null, string | null $sortOrder = null ) : Sulu\Bundle\CategoryBundle\Entity\CategoryInterface[] | ||
$key | integer | the key of the category to search the children for |
$sortBy | string | null | column name to sort by |
$sortOrder | string | null | sort order |
Результат | Sulu\Bundle\CategoryBundle\Entity\CategoryInterface[] |
/** * Returns an array of serialized categories. * * @param string $locale * @param int $parent id of parent category. null for root. * @param int $depth number of children. * * @return array */ public function getCategoriesFunction($locale, $parent = null) { return $this->memoizeCache->memoize(function ($locale, $parent = null) { if (null === $parent) { $entities = $this->categoryManager->find(); } else { $entities = $this->categoryManager->findChildren($parent); } $apiEntities = $this->categoryManager->getApiObjects($entities, $locale); $context = SerializationContext::create(); $context->setSerializeNull(true); return $this->serializer->serialize($apiEntities, 'array', $context); }); }