/** * @param Request $request * @param CategoryInterface|null $selectNode * * @return array|ArrayCollection */ protected function getChildrenCategories(Request $request, $selectNode) { $parent = $this->findCategory($request->get('id')); if (null !== $selectNode) { $categories = $this->categoryRepository->getChildrenTreeByParentId($parent->getId(), $selectNode->getId()); } else { $categories = $this->categoryRepository->getChildrenByParentId($parent->getId()); } return $categories; }