当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::message方法代码示例

本文整理汇总了PHP中Pagekit\Application::message方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::message方法的具体用法?PHP Application::message怎么用?PHP Application::message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pagekit\Application的用法示例。


在下文中一共展示了Application::message方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticateAction

 /**
  * @Route(methods="POST", defaults={"_maintenance" = true})
  * @Request({"credentials": "array", "remember_me": "boolean", "redirect": "string"})
  */
 public function authenticateAction($credentials, $remember = false, $redirect = '')
 {
     try {
         if (!App::csrf()->validate()) {
             throw new CsrfException(__('Invalid token. Please try again.'));
         }
         App::auth()->authorize($user = App::auth()->authenticate($credentials, false));
         if (($event = App::auth()->login($user, $remember)) && $event->hasResponse()) {
             return $event->getResponse();
         }
         if (App::request()->isXmlHttpRequest()) {
             return App::response()->json(['csrf' => App::csrf()->generate()]);
         } else {
             return App::redirect(preg_replace('#(https?:)?//[^/]+#', '', $redirect));
         }
     } catch (CsrfException $e) {
         if (App::request()->isXmlHttpRequest()) {
             return App::response()->json(['csrf' => App::csrf()->generate()], 401);
         }
         $error = $e->getMessage();
     } catch (BadCredentialsException $e) {
         $error = __('Invalid username or password.');
     } catch (AuthException $e) {
         $error = $e->getMessage();
     }
     if (App::request()->isXmlHttpRequest()) {
         App::abort(401, $error);
     } else {
         App::message()->error($error);
         return App::redirect(preg_replace('#(https?:)?//[^/]+#', '', App::url()->previous()));
     }
 }
开发者ID:nstaeger,项目名称:pagekit,代码行数:36,代码来源:AuthController.php

示例2: authenticateAction

 /**
  * @Route(methods="POST", defaults={"_maintenance" = true})
  * @Request({"credentials": "array", "_remember_me": "boolean"})
  */
 public function authenticateAction($credentials, $remember = false)
 {
     $isXml = App::request()->isXmlHttpRequest();
     try {
         if (!App::csrf()->validate()) {
             throw new AuthException(__('Invalid token. Please try again.'));
         }
         App::auth()->authorize($user = App::auth()->authenticate($credentials, false));
         if (!$isXml) {
             return App::auth()->login($user, $remember);
         } else {
             App::auth()->setUser($user, $remember);
             return ['success' => true];
         }
     } catch (BadCredentialsException $e) {
         $error = __('Invalid username or password.');
     } catch (AuthException $e) {
         $error = $e->getMessage();
     }
     if (!$isXml) {
         App::message()->error($error);
         return App::redirect(App::url()->previous());
     } else {
         App::abort(400, $error);
     }
 }
开发者ID:aqnouch,项目名称:rimbo,代码行数:30,代码来源:AuthController.php

示例3: confirmAction

 /**
  * @Request({"user", "key"})
  */
 public function confirmAction($username = "", $activation = "")
 {
     if (empty($username) || empty($activation) || !($user = User::where(compact('username', 'activation'))->first())) {
         return $this->messageView(__('Invalid key.'), $success = false);
     }
     if ($user->isBlocked()) {
         return $this->messageView(__('Your account has not been activated or is blocked.'), $success = false);
     }
     $error = '';
     if ('POST' === App::request()->getMethod()) {
         try {
             if (!App::csrf()->validate()) {
                 throw new Exception(__('Invalid token. Please try again.'));
             }
             $password = App::request()->request->get('password');
             if (empty($password)) {
                 throw new Exception(__('Enter password.'));
             }
             if ($password != trim($password)) {
                 throw new Exception(__('Invalid password.'));
             }
             $user->password = App::get('auth.password')->hash($password);
             $user->activation = null;
             $user->save();
             App::message()->success(__('Your password has been reset.'));
             return App::redirect('@user/login');
         } catch (Exception $e) {
             $error = $e->getMessage();
         }
     }
     return ['$view' => ['title' => __('Reset Confirm'), 'name' => 'system/user/reset-confirm.php'], 'username' => $username, 'activation' => $activation, 'error' => $error];
 }
开发者ID:nstaeger,项目名称:pagekit,代码行数:35,代码来源:ResetPasswordController.php

示例4: migrateAction

 /**
  * @Request({"redirect": "string"}, csrf=true)
  */
 public function migrateAction($redirect = null)
 {
     if ($updates = $this->scripts->hasUpdates()) {
         $this->scripts->update();
         $message = __('Your Pagekit database has been updated successfully.');
     } else {
         $message = __('Your database is up to date.');
     }
     App::config('system')->set('version', App::version());
     if ($redirect) {
         App::message()->success($message);
         return App::redirect($redirect);
     }
     return App::response()->json(compact('status', 'message'));
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:18,代码来源:MigrationController.php

示例5: authenticateAction

 /**
  * @Route(methods="POST", defaults={"_maintenance" = true})
  * @Request({"credentials": "array"})
  */
 public function authenticateAction($credentials)
 {
     try {
         if (!App::csrf()->validate()) {
             throw new AuthException(__('Invalid token. Please try again.'));
         }
         App::auth()->authorize($user = App::auth()->authenticate($credentials, false));
         return App::auth()->login($user, App::request()->get(Auth::REMEMBER_ME_PARAM));
     } catch (BadCredentialsException $e) {
         App::message()->error(__('Invalid username or password.'));
     } catch (AuthException $e) {
         App::message()->error($e->getMessage());
     }
     return App::redirect(App::url()->previous());
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:19,代码来源:AuthController.php

示例6: editAction

 /**
  * @Route("/file/edit", name="file/edit")
  * @Access("download: manage downloads")
  * @Request({"id": "int"})
  */
 public function editAction($id = 0)
 {
     try {
         if (!($file = File::where(compact('id'))->related('categories')->first())) {
             if ($id) {
                 App::abort(404, __('Invalid file id.'));
             }
             $file = File::create(['status' => 1, 'slug' => '', 'data' => [], 'tags' => [], 'date' => new \DateTime()]);
             $file->set('markdown', $this->download->config('markdown'));
         }
         return ['$view' => ['title' => $id ? __('Edit download') : __('Add download'), 'name' => 'bixie/download/admin/file.php'], '$data' => ['categories' => Category::findAll(), 'statuses' => File::getStatuses(), 'roles' => array_values(Role::findAll()), 'config' => $this->download->config(), 'file' => $file, 'tags' => File::allTags()], 'file' => $file];
     } catch (\Exception $e) {
         App::message()->error($e->getMessage());
         return App::redirect('@download/download');
     }
 }
开发者ID:Bixie,项目名称:pagekit-download,代码行数:21,代码来源:DownloadController.php

示例7: migrateAction

 /**
  * @Request({"redirect": "string"}, csrf=true)
  */
 public function migrateAction($redirect = null)
 {
     $config = App::config('system');
     $manager = new PackageManager();
     $scripts = $manager->loadScripts(null, __DIR__ . '/../../scripts.php');
     if (isset($scripts['updates'])) {
         $updates = $manager->filterUpdates($scripts['updates'], $config->get('version'));
         $manager->execute($updates);
     }
     $config->set('version', App::version());
     $message = __('Your Pagekit database has been updated successfully.');
     if ($redirect) {
         App::message()->success($message);
         return App::redirect($redirect);
     }
     return App::response()->json(compact('status', 'message'));
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:20,代码来源:MigrationController.php

示例8: editAction

 /**
  * @Route("/project/edit", name="project/edit")
  * @Access("portfolio: manage portfolio")
  * @Request({"id": "int"})
  */
 public function editAction($id = 0)
 {
     try {
         if (!($project = Project::where(compact('id'))->first())) {
             if ($id) {
                 App::abort(404, __('Invalid project id.'));
             }
             $module = App::module('bixie/portfolio');
             $project = Project::create(['data' => [], 'tags' => [], 'date' => new \DateTime()]);
             $project->set('markdown', $module->config('markdown'));
         }
         return ['$view' => ['title' => $id ? __('Edit Project') : __('Add Project'), 'name' => 'bixie/portfolio/admin/project.php'], '$data' => ['config' => App::module('bixie/portfolio')->config(), 'project' => $project, 'tags' => Project::allTags()], 'project' => $project];
     } catch (\Exception $e) {
         App::message()->error($e->getMessage());
         return App::redirect('@portfolio/post');
     }
 }
开发者ID:4nxiety,项目名称:pagekit-portfolio,代码行数:22,代码来源:PortfolioController.php

示例9: editAction

 /**
  * @Route("/post/edit", name="post/edit")
  * @Access("blog: manage own posts || blog: manage all posts")
  * @Request({"id": "int"})
  */
 public function editAction($id = 0)
 {
     try {
         if (!($post = Post::where(compact('id'))->related('user')->first())) {
             if ($id) {
                 App::abort(404, __('Invalid post id.'));
             }
             $module = App::module('blog');
             $post = Post::create(['user_id' => App::user()->id, 'status' => Post::STATUS_DRAFT, 'date' => new \DateTime(), 'comment_status' => (bool) $module->config('posts.comments_enabled')]);
             $post->set('title', $module->config('posts.show_title'));
             $post->set('markdown', $module->config('posts.markdown_enabled'));
         }
         $user = App::user();
         if (!$user->hasAccess('blog: manage all posts') && $post->user_id !== $user->id) {
             App::abort(403, __('Insufficient User Rights.'));
         }
         $roles = App::db()->createQueryBuilder()->from('@system_role')->where(['id' => Role::ROLE_ADMINISTRATOR])->whereInSet('permissions', ['blog: manage all posts', 'blog: manage own posts'], false, 'OR')->execute('id')->fetchAll(\PDO::FETCH_COLUMN);
         $authors = App::db()->createQueryBuilder()->from('@system_user')->whereInSet('roles', $roles)->execute('id, username')->fetchAll();
         return ['$view' => ['title' => $id ? __('Edit Post') : __('Add Post'), 'name' => 'blog/admin/post-edit.php'], '$data' => ['post' => $post, 'statuses' => Post::getStatuses(), 'roles' => array_values(Role::findAll()), 'canEditAll' => $user->hasAccess('blog: manage all posts'), 'authors' => $authors], 'post' => $post];
     } catch (\Exception $e) {
         App::message()->error($e->getMessage());
         return App::redirect('@blog/post');
     }
 }
开发者ID:pagekit,项目名称:extension-blog,代码行数:29,代码来源:BlogController.php

示例10: activateAction

 /**
  * @Request({"user", "key"})
  */
 public function activateAction($username, $activation)
 {
     if (empty($username) || empty($activation) || !($user = User::where(['username' => $username, 'activation' => $activation, 'status' => User::STATUS_BLOCKED, 'access IS NULL'])->first())) {
         App::message()->error(__('Invalid key.'));
         return App::redirect();
     }
     if ($admin = $this->module->config('registration') == 'approval' and !$user->get('verified')) {
         $user->activation = App::get('auth.random')->generateString(32);
         $this->sendApproveMail($user);
         App::message()->success(__('Your email has been verified. Once an administrator approves your account, you will be notified by email.'));
     } else {
         $user->set('verified', true);
         $user->status = User::STATUS_ACTIVE;
         $user->activation = '';
         $this->sendWelcomeEmail($user);
         if ($admin) {
             App::message()->success(__('The user\'s account has been activated and the user has been notified about it.'));
         } else {
             App::message()->success(__('Your account has been activated.'));
         }
     }
     $user->save();
     return App::redirect('@user/login');
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:27,代码来源:RegistrationController.php


注:本文中的Pagekit\Application::message方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。