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


PHP Application::trigger方法代码示例

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


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

示例1: getPermissions

 /**
  * @return array
  */
 public function getPermissions()
 {
     if (!$this->perms) {
         foreach (App::module() as $module) {
             if ($perms = $module->get('permissions')) {
                 $this->registerPermissions($module->get('name'), $perms);
             }
         }
         App::trigger('user.permission', [$this]);
     }
     return $this->perms;
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:15,代码来源:UserModule.php

示例2: getTypes

 /**
  * @return array
  */
 public function getTypes()
 {
     if (!$this->types) {
         foreach (App::module() as $module) {
             foreach ((array) $module->get('nodes') as $type => $route) {
                 $this->registerType($type, $route);
             }
         }
         $this->registerType('link', ['label' => 'Link', 'frontpage' => false]);
         App::trigger('site.types', [$this]);
     }
     return $this->types;
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:16,代码来源:SiteModule.php

示例3: enable

 /**
  * @param $packages
  */
 public function enable($packages)
 {
     if (!is_array($packages)) {
         $packages = [$packages];
     }
     foreach ($packages as $package) {
         App::trigger('package.enable', [$package]);
         if (!($current = App::config('system')->get('packages.' . $package->get('module')))) {
             $current = $this->doInstall($package);
         }
         $scripts = $this->getScripts($package, $current);
         if ($scripts->hasUpdates()) {
             $scripts->update();
         }
         $version = $this->getVersion($package);
         App::config('system')->set('packages.' . $package->get('module'), $version);
         $scripts->enable();
         if ($package->getType() == 'pagekit-theme') {
             App::config('system')->set('site.theme', $package->get('module'));
         } elseif ($package->getType() == 'pagekit-extension') {
             App::config('system')->push('extensions', $package->get('module'));
         }
     }
 }
开发者ID:pagekit,项目名称:pagekit,代码行数:27,代码来源:PackageManager.php

示例4: getMode

 protected function getMode($path)
 {
     $mode = App::trigger(new FileAccessEvent('system.finder'))->mode($path);
     if ('w' == $mode && !is_writable($path)) {
         $mode = 'r';
     }
     if ('r' == $mode && !is_readable($path)) {
         $mode = '-';
     }
     return $mode;
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:11,代码来源:FinderController.php

示例5: fileAction

 /**
  * @Route("/{id}", name="id")
  * @Request({"id":"int", "category_id":"int"})
  */
 public function fileAction($id = 0, $category_id = 0)
 {
     /** @var File $file */
     if (!($file = File::where(['id = ?', 'status = ?'], [$id, '1'])->where(function ($query) {
         return $query->where('roles IS NULL')->whereInSet('roles', App::user()->roles, false, 'OR');
     })->first())) {
         App::abort(404, __('File not found.'));
     }
     $file->setActiveCategory($category_id);
     App::trigger('bixie.prepare.file', [$file, App::view()]);
     $file->content = App::content()->applyPlugins($file->content, ['file' => $file, 'markdown' => $file->get('markdown')]);
     $previous = File::getPrevious($file);
     $next = File::getNext($file);
     /** @var Category $category */
     if ($category_id && !($category = Category::where(['id = ?', 'status = ?'], [$category_id, '1'])->where(function ($query) {
         return $query->where('roles IS NULL')->whereInSet('roles', App::user()->roles, false, 'OR');
     })->related('files')->first())) {
         App::abort(404, __('Category not found.'));
     }
     if ($breadcrumbs = App::module('bixie/breadcrumbs')) {
         if ($category_id) {
             $cat = $category;
             $crumbs = [['title' => $category->title, 'url' => $category->getUrl()]];
             while ($parent_id = $cat->parent_id) {
                 if ($cat = $cat->find($parent_id, true)) {
                     $crumbs[] = ['title' => $cat->title, 'url' => $cat->getUrl()];
                 }
             }
             foreach (array_reverse($crumbs) as $data) {
                 $breadcrumbs->addUrl($data);
             }
         }
         //add file
         $breadcrumbs->addUrl(['title' => $file->title, 'url' => $file->getUrl()]);
     }
     return ['$view' => ['title' => __($file->title), 'name' => 'bixie/download/file.php'], 'download' => $this->download, 'config' => $this->download->config(), 'previous' => $previous, 'next' => $next, 'file' => $file, 'node' => App::node()];
 }
开发者ID:Bixie,项目名称:pagekit-download,代码行数:41,代码来源:SiteController.php

示例6: applyPlugins

 /**
  * Applies content plugins
  *
  * @param  string $content
  * @param  array  $parameters
  * @return mixed
  */
 public function applyPlugins($content, $parameters = [])
 {
     return App::trigger(new ContentEvent('content.plugins', $content, $parameters))->getContent();
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:11,代码来源:ContentHelper.php

示例7: saveAction

 /**
  * @Route("/", methods="POST")
  * @Route("/{id}", methods="POST", requirements={"id"="\d+"})
  * @Request({"submission": "array", "id": "int", "g-recaptcha-response": "string"}, csrf=true)
  */
 public function saveAction($data, $id = 0, $gRecaptchaResponse = '')
 {
     if (!($submission = Submission::find($id))) {
         $submission = Submission::create();
         unset($data['id']);
         $submission->form_id = $data['form_id'];
         $submission->created = new \DateTime();
         $submission->ip = App::request()->getClientIp();
     }
     unset($data['created']);
     if (!($form = Form::find($submission->form_id))) {
         App::abort(404, 'Form not found.');
     }
     $submission->form = $form;
     if ($form->get('recaptcha') and $id == 0 and $recaptha_secret_key = App::module('bixie/formmaker')->config('recaptha_secret_key')) {
         $resp = (new ReCaptcha($recaptha_secret_key))->verify($gRecaptchaResponse, App::request()->server->get('REMOTE_ADDR'));
         if (!$resp->isSuccess()) {
             $errors = $resp->getErrorCodes();
             App::abort(403, isset($errors[0]) ? $errors[0] : 'Error in reCaptcha');
         }
     }
     $submission->save($data);
     $submission->email = $submission->getUserEmail();
     if ($id == 0) {
         App::trigger('formmaker.form.submission', [$form, $submission]);
         try {
             (new MailHelper($submission))->sendMail();
             $submission->save();
         } catch (Exception $e) {
             App::abort(400, $e->getMessage());
         }
     }
     return ['message' => 'Submission successful', 'submission' => $submission];
 }
开发者ID:Bixie,项目名称:pagekit-formmaker,代码行数:39,代码来源:SubmissionApiController.php


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