/**
  * @param EditCategoryRequest $request
  */
 public function execute(EditCategoryRequest $request)
 {
     $category = $this->categoryRepository->findById($request->getCategoryId());
     $category->compose($request->getName());
     $this->categoryRepository->update($category);
     $this->categoryUpdated();
 }
 /**
  * @param CreateCategoryRequest $request
  */
 public function execute(CreateCategoryRequest $request)
 {
     $category = $this->categoryFactory->create($request->getName());
     $this->categoryRepository->add($category);
     $this->treeManager->assignParent($category, $request->getParent());
     $this->categoryCreated();
 }
 /**
  * @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);
 }