private function handleSubmitedForm(Website $website, Request $request) { $text = $website->getText(); if (Validate::stringLength($this->menuName, 1, MenuRepository::NAME_MAX_LENGTH)) { $menuRepo = new MenuRepository($website->getDatabase()); $this->menu = Menu::createNew($this->menuName); $menuRepo->saveMenu($this->menu); $text->addMessage($text->t("links.menu.created")); } else { $text->addError($text->t("links.menu.name") . ' ' . Validate::getLastError($text)); } }
/** * Creates a new menu. Doesn't save to the database automatically. * @param string $menuName Name of the menu. * @return Menu The menu. */ public static function createNew($menuName) { $menu = new Menu(); $menu->setName($menuName); return $menu; }
/** * Deletes all links in the given menu. This method does nothing if the menu is empty. * @param Menu $menu The menu. * @throws PDOException If a database error occurs. */ public function deleteLinksInMenu(Menu $menu) { $this->where($this->menuIdField, '=', $menu->getId())->delete(); }