find() public method

Returns tags with a given parent and/or a given depth-level if no arguments passed returns all categories.
Deprecation: Use ::findChildrenByParentId instead
public find ( integer $parent = null, integer $depth = null, string | null $sortBy = null, string | null $sortOrder = null ) : Sulu\Bundle\CategoryBundle\Entity\CategoryInterface[]
$parent integer the id of the parent to filter for
$depth integer the depth-level to filter for
$sortBy string | null column name to sort the categories by
$sortOrder string | null sort order
return Sulu\Bundle\CategoryBundle\Entity\CategoryInterface[]
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);
     });
 }