Sulu\Bundle\CategoryBundle\Category\CategoryManagerInterface::findChildren PHP Method

findChildren() public method

Returns the children for a given category.
Deprecation: Use ::findChildrenByParentKey instead
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
return Sulu\Bundle\CategoryBundle\Entity\CategoryInterface[]
    public function findChildren($key, $sortBy = null, $sortOrder = null);

Usage Example

示例#1
0
 /**
  * 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);
     });
 }