/** * Test `Is` Methods */ public function testIsMethods() { $this->assertTrue(Request::isGet()); $this->assertFalse(Request::isPost()); $this->assertFalse(Request::isPut()); $this->assertFalse(Request::isDelete()); $this->assertFalse(Request::isFlashRequest()); $this->assertFalse(Request::isXmlHttpRequest()); }
return function ($email = null, $password = null, $token = null) { /** * @var Controller $this */ // change layout $this->useLayout('small.phtml'); $userId = $this->user() ? $this->user()->id : null; /** * @var Users\Row $user */ $user = Users\Table::findRow($userId); if (!$user) { throw new NotFoundException('User not found'); } $this->assign('email', $user->email); if (Request::isPost()) { // process form try { if (empty($password)) { throw new Exception('Password is empty'); } // login/password Auth\Table::getInstance()->checkEquals($user->login, $password); // check email for unique $emailUnique = Users\Table::findRowWhere(['email' => $email]); if ($emailUnique && $emailUnique->id != $userId) { throw new Exception('User with email "' . htmlentities($email) . '" already exists'); } // generate change mail token and get full url $actionRow = UsersActions\Table::getInstance()->generate($userId, Table::ACTION_CHANGE_EMAIL, 5, ['email' => $email]); $changeUrl = Router::getFullUrl('users', 'change-email', ['token' => $actionRow->code]);