/**
  * List categories associated with the provided product and descending from the category
  * defined by the parent parameter.
  *
  * @param Request        $request    The request object
  * @param integer|string $id         Product id
  * @param integer        $categoryId The parent category id
  *
  * httpparam include_category if true, will include the parentCategory in the response
  *
  * @Template
  * @AclAncestor("pim_enrich_product_categories_view")
  * @return array
  */
 public function listCategoriesAction(Request $request, $id, $categoryId)
 {
     $product = $this->findProductOr404($id);
     $parent = $this->findOr404($this->categoryManager->getCategoryClass(), $categoryId);
     $categories = null;
     $includeParent = $request->get('include_parent', false);
     $includeParent = $includeParent === 'true';
     if ($product !== null) {
         $categories = $product->getCategories();
     }
     $trees = $this->getFilledTree($parent, $categories);
     return ['trees' => $trees, 'categories' => $categories];
 }