/** * @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); }
public function execute() { $units = $this->unitRepository->findAll(); $items = $this->fetchList($units); $this->unitListFetched($items); }