/**
  * @param CreateMaterialRequest $request
  */
 public function execute(CreateMaterialRequest $request)
 {
     $category = $request->getCategory();
     if (count($category->getChildren())) {
         $this->callWarningLimitationAssignOnlyToLeaf($category);
         return;
     }
     $material = $this->materialFactory->create($request->getName(), $request->getCode(), $request->getCategory(), $request->getUnit());
     $this->materialRepository->add($material);
 }
 /**
  * @param EditMaterialRequest $request
  */
 public function execute(EditMaterialRequest $request)
 {
     $material = $this->materialRepository->findById($request->getMaterialId());
     $category = $request->getCategory();
     if (count($category->getChildren())) {
         $this->callWarningLimitationAssignOnlyToLeaf($category);
         return;
     }
     $material->compose($request->getNewName(), $request->getNewCode());
     $material->setCategory($category);
     $material->setUnit($request->getUnit());
     $this->materialRepository->update($material);
 }
 public function execute()
 {
     $materials = $this->materialsRepository->findAll();
     $items = $this->fetchItems($materials);
     $this->listFetched($items);
 }