public function register() { if (!$this->path) { throw new \Exception(t('Page path not defined')); } // add menu item if ($this->menu && $this->isUserAllowed()) { $this->menu->path = $this->path; // set menu label same as page title if (!$this->menu->label) { $this->menu->label = $this->title; } Menu::get()->add($this->menu); } // add route callback $obj = $this; Route::get()->add($this->path, function () use($obj) { if (!$obj->isUserAllowed()) { if (!User::hasLoggedUser()) { redirect(page_login()); } echo new Page\AccessDenied(); } echo $obj->render(); }); }