private function getActive() : Entity { if ($this->active === NULL) { $menu = $this->repository->getByMenuAndDestinationAndParameters($this->menu, $destination = $this->getPresenter()->getAction(TRUE), array_map(function ($parameter) { return $parameter instanceof Nextras\Orm\Entity\IEntity ? $parameter->getPersistedId() : $parameter; }, $this->getPresenter()->getRequest()->getParameters())); if (!$menu) { $destination = substr($destination, 0, -strlen($this->getPresenter()->getAction())); foreach ($this->menu->getterChildren(TRUE) as $child) { if (strpos($child->link->destination, $destination) !== FALSE) { $menu = $child; break; } } } $this->active = $menu ?: $this->menu; } return $this->active; }
public function actionEdit(int $id) { if (!($this->entity = $this->repository->getById($id))) { $this->error(); } }