/** * Removes child albums that belong to provided id * * @param string $parentId * @return boolean */ private function removeChildCategoriesByParentId($parentId) { $treeBuilder = new TreeBuilder($this->categoryMapper->fetchAll()); $ids = $treeBuilder->findChildNodeIds($parentId); // If there's at least one child id, then start working next if (!empty($ids)) { foreach ($ids as $id) { $this->removeAllById($id); } } return true; }
/** * Fetches all categories as a tree * * @return array */ public function fetchAllAsTree() { $treeBuilder = new TreeBuilder($this->categoryMapper->fetchAll()); return $treeBuilder->render(new PhpArray('title')); }