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

findChildrenByParentKey() public method

If parentKey is set, only the sub-graph below the category which is assigned to the given key is returned.
public findChildrenByParentKey ( null $parentKey = null ) : array
$parentKey null
return array
    public function findChildrenByParentKey($parentKey = null);

Usage Example

Example #1
0
 /**
  * Returns an array of serialized categories.
  * If parentKey is set, only the children of the category which is assigned to the given key are returned.
  *
  * @param string $locale
  * @param string $parentKey key of parent category
  *
  * @return array
  */
 public function getCategoriesFunction($locale, $parentKey = null)
 {
     return $this->memoizeCache->memoize(function ($locale, $parentKey = null) {
         $entities = $this->categoryManager->findChildrenByParentKey($parentKey);
         $categories = $this->categoryManager->getApiObjects($entities, $locale);
         $context = SerializationContext::create();
         $context->setSerializeNull(true);
         return $this->serializer->serialize($categories, 'array', $context);
     });
 }