/** * @param Nyaan\Application $app * @return string */ public function render(\Baguette\Application $app) { $token = csrf_token(); $app->session->set('token', $token); $params = $this->params + ['server' => $app->server, 'cookie' => $app->cookie, 'get' => $app->get, 'post' => $app->post, 'now' => $app->now, 'isLoggedIn' => $app->isLoggedIn(), 'loginUser' => $app->getLoginUser(), 'token' => $token]; return static::$twig->render($this->tpl_name, $params); }
function action(\Baguette\Application $app, \Teto\Routing\Action $action) { $is_daburi = self::isTyouhuku(isset($_REQUEST['slug']) ?? ''); if (!$is_daburi && isset($_REQUEST['slug'], $_REQUEST['name']) && self::regist($_REQUEST['slug'], $_REQUEST['name'], $app->getLoginUser())) { return new Response\RedirectResponse('/rooms/' . $_REQUEST['slug']); } return new Response\RedirectResponse('/'); }
function action(\Baguette\Application $app, \Teto\Routing\Action $action) { //setされていない時はすぐに返してよし //変数名もっとまともなのに変える。isOverlapRet? あとキャメルケースで統一したい。 $is_daburi = self::isTyouhuku(isset($_REQUEST['slug']) ?? ''); //条件と関数は分ける!registは必ずtrueがかえってくるので、if文の条件式ではなくif文内で行う if (!$is_daburi && isset($_REQUEST['slug'], $_REQUEST['name']) && self::regist($_REQUEST['slug'], $_REQUEST['name'], $app->getLoginUser())) { return new Response\RedirectResponse('/rooms/' . $_REQUEST['slug']); } return new Response\RedirectResponse('/'); }
function action(\Baguette\Application $app, \Teto\Routing\Action $action) { $slug = NULL; if (isset($_REQUEST['slug'])) { preg_match('/[-a-zA-Z0-9]+/', $_REQUEST['slug'], $matches); if (count($matches) > 0) { $slug = $matches[0]; } } $is_daburi = $slug === NULL || self::isTyouhuku($slug); if (!$is_daburi && isset($_REQUEST['slug'], $_REQUEST['name']) && $app->isTokenVerified && self::register($_REQUEST['slug'], $_REQUEST['name'], $app->getLoginUser())) { return new Response\RedirectResponse('/rooms/' . $_REQUEST['slug']); } return new Response\RedirectResponse('/'); }