/** * @param string $name * @return CategoryInterface */ private function getCategoryFromListByName($name) { /** @var CategoryInterface[] $items */ $items = array_filter($this->categoryRepository->findAll(), function (CategoryInterface $category) use($name) { return $category->getName() == $name; }); $id = null; if (count($items)) { $id = array_values($items)[0]->getId(); } return $this->categoryRepository->findById($id); }
/** * */ public function execute() { $categories = $this->categoryRepository->findAll(); $items = $this->fetchCategoriesItems($categories); $this->listFetched($items); }