/**
  * @param EditUnitRequest $request
  */
 public function execute(EditUnitRequest $request)
 {
     $unit = $this->unitRepository->findById($request->getUnitId());
     if (is_null($unit)) {
         $this->unitNotFound();
         return;
     }
     $unit->compose($request->getName(), $request->getShortcut());
     $this->unitRepository->update($unit);
     $this->unitUpdated($unit);
 }
 /**
  * @param string $name
  * @return UnitInterface
  */
 private function getUnitFromListByName($name)
 {
     /** @var UnitInterface[] $items */
     $items = array_filter($this->unitRepository->findAll(), function (UnitInterface $unit) use($name) {
         return $unit->getName() == $name;
     });
     $id = null;
     if (count($items)) {
         $id = array_values($items)[0]->getId();
     }
     return $this->unitRepository->findById($id);
 }
 /**
  * @param CreateUnitRequest $request
  */
 public function execute(CreateUnitRequest $request)
 {
     $unit = $this->unitFactory->create($request->getName(), $request->getShortcut());
     $this->unitRepository->add($unit);
     $this->unitCreated($unit);
 }
 public function execute()
 {
     $units = $this->unitRepository->findAll();
     $items = $this->fetchList($units);
     $this->unitListFetched($items);
 }