• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Events\Dispatcher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Illuminate\Contracts\Events\Dispatcher的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher类的具体用法?PHP Dispatcher怎么用?PHP Dispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: handle

 /**
  * Execute the command.
  *
  * @param ContentType $contentType
  * @param Validator $validator
  * @param Dispatcher $dispatcher
  * @return CommandResult
  */
 public function handle(ContentType $contentType, Validator $validator, Dispatcher $dispatcher)
 {
     // validate authorization
     if (!$this->disablePermissionChecking) {
         if (!$this->user->hasAnyPermission(['contentBuilder.manage'])) {
             return new CommandResult(false, CommandResult::$responseForbiddenMessage, null, 403);
         }
     }
     // validate data
     $validationResult = $validator->make(array('taxonomy' => $this->taxonomy, 'content_type_id' => $this->contentTypeId), ContentTypeTaxonomy::$rules);
     if ($validationResult->fails()) {
         return new CommandResult(false, $validationResult->getMessageBag()->first(), null, 400);
     }
     // prepare the data to be stored
     $taxonomyToBeCreated = array('taxonomy' => $this->taxonomy, 'description' => $this->description);
     // fire creating event
     $dispatcher->fire('contentTypeTaxonomy.creating', array($taxonomyToBeCreated));
     // store
     try {
         $contentType = $contentType->findOrFail($this->contentTypeId);
         $createdContentTypeTaxonomy = $contentType->taxonomies()->create($taxonomyToBeCreated);
     } catch (\Exception $e) {
         return new CommandResult(false, "Invalid Content Type.", null, 400);
     }
     // fire creating event
     $dispatcher->fire('contentTypeTaxonomy.created', array($createdContentTypeTaxonomy));
     // return
     return new CommandResult(true, "Content type taxonomy successfully created.", $createdContentTypeTaxonomy, 201);
 }
开发者ID:darryldecode,项目名称:laravelbackend,代码行数:37,代码来源:CreateContentTypeTaxonomyCommand.php


示例2: __construct

 public function __construct($options = [], Application $app = null, RepositoryContract $config = null, Dispatcher $dispatcher = null)
 {
     static::$options = $config !== null ? array_merge($options, $config->get('tracy')) : $options;
     TracyDebugger::$time = array_get($_SERVER, 'REQUEST_TIME_FLOAT', microtime(true));
     TracyDebugger::$maxDepth = array_get(static::$options, 'maxDepth');
     TracyDebugger::$maxLen = array_get(static::$options, 'maxLen');
     TracyDebugger::$showLocation = array_get(static::$options, 'showLocation');
     TracyDebugger::$strictMode = array_get(static::$options, 'strictMode');
     TracyDebugger::$editor = array_get(static::$options, 'editor');
     $bar = TracyDebugger::getBar();
     foreach (array_get(static::$options, 'panels') as $key => $enabled) {
         if ($enabled === true) {
             $class = '\\' . __NAMESPACE__ . '\\Panels\\' . ucfirst($key) . 'Panel';
             if (class_exists($class) === false) {
                 $class = $key;
             }
             $this->panels[$key] = new $class($app, static::$options);
             $bar->addPanel($this->panels[$key], $class);
         }
     }
     if ($dispatcher !== null) {
         $dispatcher->listen('kernel.handled', function ($request, $response) {
             return static::appendDebugbar($request, $response);
         });
     } else {
         TracyDebugger::enable();
     }
 }
开发者ID:dasim,项目名称:laravel-tracy,代码行数:28,代码来源:Debugger.php


示例3: handle

 public function handle(Navigation $navigation, Factory $validator, Dispatcher $dispatcher)
 {
     // check if user has permission
     if (!$this->disablePermissionChecking) {
         if (!$this->user->hasAnyPermission(['navigationBuilder.manage'])) {
             return new CommandResult(false, "Not enough permission.", null, 403);
         }
     }
     // validate data
     $validationResult = $validator->make(array('name' => $this->name, 'data' => $this->data), Navigation::$rules);
     if ($validationResult->fails()) {
         return new CommandResult(false, $validationResult->getMessageBag()->first(), null, 400);
     }
     if (!($nav = $navigation->find($this->id))) {
         return new CommandResult(false, 'Navigation does not exist.', null, 400);
     }
     // fire before create event
     $dispatcher->fire('navigationBuilder.updating', array($nav, $this->args));
     $nav->name = $this->name;
     $nav->data = $this->data;
     $nav->save();
     // fire after create
     $dispatcher->fire('navigationBuilder.updated', array($nav, $this->args));
     // all good
     return new CommandResult(true, "Navigation successfully updated.", $nav, 200);
 }
开发者ID:darryldecode,项目名称:laravelbackend,代码行数:26,代码来源:UpdateNavigationCommand.php


示例4: subscribe

 public function subscribe(Dispatcher $events)
 {
     $events->listen(RegisterPostTypes::class, [$this, 'registerPostType']);
     $events->listen(RegisterNotificationTypes::class, [$this, 'registerNotificationType']);
     $events->listen(DiscussionWasStickied::class, [$this, 'whenDiscussionWasStickied']);
     $events->listen(DiscussionWasUnstickied::class, [$this, 'whenDiscussionWasUnstickied']);
 }
开发者ID:redstarxz,项目名称:flarumone,代码行数:7,代码来源:NotifyDiscussionStickied.php


示例5: subscribe

 /**
  * Register the listeners for the subscriber.
  *
  * @param \Illuminate\Contracts\Events\Dispatcher $events
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen('Flarum\\Core\\Events\\PostWasPosted', __CLASS__ . '@whenPostWasPosted');
     $events->listen('Flarum\\Core\\Events\\PostWasDeleted', __CLASS__ . '@whenPostWasDeleted');
     $events->listen('Flarum\\Core\\Events\\PostWasHidden', __CLASS__ . '@whenPostWasHidden');
     $events->listen('Flarum\\Core\\Events\\PostWasRestored', __CLASS__ . '@whenPostWasRestored');
 }
开发者ID:Qiang1234,项目名称:core,代码行数:12,代码来源:DiscussionMetadataUpdater.php


示例6: registerMenu

 public static function registerMenu(Dispatcher $events, Repository $config)
 {
     $events->listen(BuildingMenu::class, function (BuildingMenu $event) use($config) {
         $menu = $config->get('adminlte.menu');
         call_user_func_array([$event->menu, 'add'], $menu);
     });
 }
开发者ID:jeroennoten,项目名称:laravel-adminlte,代码行数:7,代码来源:ServiceProvider.php


示例7: subscribe

 /**
  * @param Dispatcher $events
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen(ConfigurePostTypes::class, [$this, 'addPostType']);
     $events->listen(ConfigureNotificationTypes::class, [$this, 'addNotificationType']);
     $events->listen(DiscussionWasLocked::class, [$this, 'whenDiscussionWasLocked']);
     $events->listen(DiscussionWasUnlocked::class, [$this, 'whenDiscussionWasUnlocked']);
 }
开发者ID:lazyboywu,项目名称:edufunbbs,代码行数:10,代码来源:CreatePostWhenDiscussionIsLocked.php


示例8: handle

 /**
  * Execute the command.
  *
  * @param Filesystem $fileSystem
  * @param Application $app
  * @param TranslationRepositoryInterface $repository
  * @param Dispatcher $event
  * @return Collection of Group
  */
 public function handle(Filesystem $fileSystem, Application $app, TranslationRepositoryInterface $repository, Dispatcher $event)
 {
     $files = $fileSystem->allFiles($app->langPath());
     /**
      * Retrieves all local languages
      */
     $languages = collect($files)->transform(function ($file) {
         return $file->getRelativePath();
     })->unique();
     /**
      * Save Database instance with all languages
      */
     $database = $repository->languages();
     /**
      * List Only names
      */
     $names = $database->pluck('name');
     /**
      * Create New Language for those which has been set locally
      * but was not present yet on the database
      */
     $newLanguages = $languages->merge($names)->diff($names)->map(function ($name) {
         return $this->dispatch(new CreateLanguageCommand($name));
     });
     /**
      * Announce LanguagesWasCreated
      */
     if (!$newLanguages->isEmpty()) {
         $event->fire(new LanguagesWasCreated($newLanguages));
     }
     /**
      * Returns All languages
      */
     return $database->merge($newLanguages);
 }
开发者ID:SkysoulDesign,项目名称:TempArk,代码行数:44,代码来源:ImportLanguagesCommand.php


示例9: subscribe

 /**
  * @param Dispatcher $events
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen(GetModelRelationship::class, [$this, 'getModelRelationship']);
     $events->listen(GetApiRelationship::class, [$this, 'getApiRelationship']);
     $events->listen(ConfigureApiController::class, [$this, 'includeRelationships']);
     $events->listen(PrepareApiData::class, [$this, 'filterVisiblePosts']);
 }
开发者ID:flarum,项目名称:flarum-ext-mentions,代码行数:10,代码来源:AddPostMentionedByRelationship.php


示例10: handle

 /**
  * @param ContentType $contentType
  * @param Dispatcher $dispatcher
  * @return CommandResult
  */
 public function handle(ContentType $contentType, Dispatcher $dispatcher)
 {
     // begin before query
     $dispatcher->fire('contentType.beforeQuery', array($this->args));
     // check if has permission
     if (!$this->disablePermissionChecking) {
         // if $type->type is not provided, the request referrer should be from
         // the admin UI Content Type Builder component.
         // so we will check if the user has permission (contentBuilder.manage)
         // on the other hand,
         // if $type->type is provided, we will check if user has permission to manage that type
         if (!is_null($this->type) && $this->type != '') {
             if (!$this->user->hasAnyPermission([$this->type . '.manage'])) {
                 return new CommandResult(false, "Not enough permission.", null, 403);
             }
         } else {
             if (!$this->user->hasAnyPermission(['contentBuilder.manage'])) {
                 return new CommandResult(false, "Not enough permission.", null, 403);
             }
         }
     }
     // begin query
     $results = $contentType->with(array('terms.taxonomy', 'taxonomies', 'taxonomies.terms', 'formGroups'))->ofType($this->type)->get();
     // begin after query
     $dispatcher->fire('contentType.afterQuery', array($this->args));
     // all good
     return new CommandResult(true, "Query content types successful.", $results, 200);
 }
开发者ID:darryldecode,项目名称:laravelbackend,代码行数:33,代码来源:QueryContentTypeCommand.php


示例11:

 function it_can_raise_events(Dispatcher $dispatcher)
 {
     $this->beAnInstanceOf('spec\\FluxBB\\Core\\EventAction');
     $dispatcher->fire('stdClass', [new \stdClass()])->shouldBeCalled();
     $this->setEvents($dispatcher);
     $this->execute();
 }
开发者ID:fluxbb,项目名称:core,代码行数:7,代码来源:ActionSpec.php


示例12: subscribe

 /**
  * @param Dispatcher $events
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen(GetApiRelationship::class, [$this, 'getApiRelationship']);
     $events->listen(PrepareApiData::class, [$this, 'loadTagsRelationship']);
     $events->listen(ConfigureApiController::class, [$this, 'includeTagsRelationship']);
     $events->listen(PrepareApiAttributes::class, [$this, 'prepareApiAttributes']);
 }
开发者ID:cmaas,项目名称:tags,代码行数:10,代码来源:AddForumTagsRelationship.php


示例13: handle

 /**
  * Handle the command.
  *
  * @param Dispatcher $events
  */
 public function handle(Dispatcher $events)
 {
     $this->builder->fire('posting', ['builder' => $this->builder]);
     $this->builder->fireFieldEvents('form_posting');
     $this->dispatch(new LoadFormValues($this->builder));
     /**
      * Multiple form builders do not get
      * validated here.. in fact:
      *
      * @todo: Decouple validation into it's own method like multiple form builders
      */
     if (!$this->builder instanceof MultipleFormBuilder) {
         $this->dispatch(new ValidateForm($this->builder));
     }
     $this->dispatch(new RemoveSkippedFields($this->builder));
     $this->dispatch(new HandleForm($this->builder));
     $this->dispatch(new SetSuccessMessage($this->builder));
     $this->dispatch(new SetActionResponse($this->builder));
     if ($this->builder->isAjax()) {
         $this->dispatch(new SetJsonResponse($this->builder));
     }
     $this->builder->fire('posted', ['builder' => $this->builder]);
     $this->builder->fireFieldEvents('form_posted');
     $events->fire(new FormWasPosted($this->builder));
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:30,代码来源:PostForm.php


示例14: setupListener

 /**
  * setting up listener
  *
  * @param Dispatcher $events
  * @param Writer $log
  */
 private function setupListener(Dispatcher $events, Writer $log)
 {
     $environments = config('slow-query-logger.environments', []);
     if (!$this->app->environment($environments)) {
         return;
     }
     $events->listen(QueryExecuted::class, function (QueryExecuted $queryExecuted) use($log) {
         $sql = $queryExecuted->sql;
         $bindings = $queryExecuted->bindings;
         $time = $queryExecuted->time;
         $logSqlQueriesSlowerThan = config('slow-query-logger.time-to-log');
         if ($logSqlQueriesSlowerThan < 0 || $time < $logSqlQueriesSlowerThan) {
             return;
         }
         $level = config('slow-query-logger.log-level', 'debug');
         try {
             foreach ($bindings as $val) {
                 $sql = preg_replace('/\\?/', "'{$val}'", $sql, 1);
             }
             $log->log($level, $time . '  ' . $sql);
         } catch (\Exception $e) {
             //  be quiet on error
         }
     });
 }
开发者ID:rokde,项目名称:laravel-slow-query-logger,代码行数:31,代码来源:LaravelSlowQueryLoggerProvider.php


示例15: handle

 /**
  * @param Factory $validator
  * @param Dispatcher $dispatcher
  * @param ContentType $contentType
  * @param ContentTypeFormGroup $contentTypeFormGroup
  * @return CommandResult
  */
 public function handle(Factory $validator, Dispatcher $dispatcher, ContentType $contentType, ContentTypeFormGroup $contentTypeFormGroup)
 {
     // check if user has permission
     if (!$this->disablePermissionChecking) {
         if (!$this->user->hasAnyPermission(['contentBuilder.manage'])) {
             return new CommandResult(false, "Not enough permission.", null, 403);
         }
     }
     // validate data
     $validationResult = $validator->make(array('name' => $this->name, 'form_name' => $this->formName, 'fields' => $this->fields, 'content_type_id' => $this->contentTypeId), ContentTypeFormGroup::$rules);
     if ($validationResult->fails()) {
         return new CommandResult(false, $validationResult->getMessageBag()->first(), null, 400);
     }
     // fire event creating
     $dispatcher->fire('formGroup.creating', array($this->args));
     // begin create
     if (!($cType = $contentType->find($this->contentTypeId))) {
         return new CommandResult(false, "Content Type Not Found.", null, 400);
     }
     $createdFormGroup = $cType->formGroups()->create(array('name' => $this->name, 'form_name' => $this->formName, 'conditions' => $this->conditions, 'fields' => $this->fields, 'content_type_id' => $this->contentTypeId));
     // fire event creating
     $dispatcher->fire('formGroup.created', array($createdFormGroup));
     // all good
     return new CommandResult(true, "Form group successfully created.", $createdFormGroup, 201);
 }
开发者ID:darryldecode,项目名称:laravelbackend,代码行数:32,代码来源:CreateFormGroupCommand.php


示例16: fireEvent

 /**
  * Fire off an event.
  *
  * @param  string  $name
  * @param  mixed   $payload
  * @return mixed
  */
 protected function fireEvent($name, $payload = null)
 {
     if (!isset(static::$dispatcher)) {
         $this->initEventDispatcher();
     }
     static::$dispatcher->fire($name, $payload);
 }
开发者ID:caffeinated,项目名称:beverage,代码行数:14,代码来源:EventDispatcher.php


示例17: handle

 /**
  * handle group creation logic
  *
  * @param Validator $validator
  * @param Dispatcher $dispatcher
  * @param Group $group
  * @return CommandResult
  */
 public function handle(Validator $validator, Dispatcher $dispatcher, Group $group)
 {
     // check user permission
     if (!$this->disablePermissionChecking) {
         if (!$this->user->hasAnyPermission(['user.manage'])) {
             return new CommandResult(false, CommandResult::$responseForbiddenMessage, null, 403);
         }
     }
     // validate data
     $validationResult = $validator->make(array('name' => $this->name, 'permissions' => $this->permissions), Group::$rules);
     if ($validationResult->fails()) {
         return new CommandResult(false, $validationResult->getMessageBag()->first(), null, 400);
     }
     // prepare data to be store
     $groupToBeCreated = array('name' => $this->name, 'permissions' => $this->transform($this->permissions));
     // fire creating
     $dispatcher->fire('group.creating', array($groupToBeCreated));
     // create
     $createdGroup = $group->create($groupToBeCreated);
     if (!$createdGroup) {
         return new CommandResult(false, "Failed to create user.", null, 400);
     }
     // fire created user
     $dispatcher->fire('group.created', array($createdGroup));
     // return response
     return new CommandResult(true, "Group successfully created.", $createdGroup, 201);
 }
开发者ID:darryldecode,项目名称:laravelbackend,代码行数:35,代码来源:CreateGroupCommand.php


示例18: handle

 /**
  * handle user deletion logic
  *
  * @param User $user
  * @param Group $group
  * @param Dispatcher $dispatcher
  * @param Repository $config
  * @return CommandResult
  */
 public function handle(User $user, Group $group, Dispatcher $dispatcher, Repository $config)
 {
     // check user permission
     if (!$this->disablePermissionChecking) {
         if (!$this->user->hasAnyPermission(['user.delete'])) {
             return new CommandResult(false, CommandResult::$responseForbiddenMessage, null, 403);
         }
         if ($this->user->id == $this->id) {
             return new CommandResult(false, "Cannot delete self.", null, 400);
         }
     }
     // prepare the user model
     $user = $this->createUserModel($user, $config);
     // find the user
     if (!($userToBeDelete = $user->find($this->id))) {
         return new CommandResult(false, "User not found.", null, 404);
     }
     // fire deleting
     $dispatcher->fire('user.deleting', array($this->args));
     // begin deletion
     $userToBeDelete->groups()->detach();
     $userToBeDelete->delete();
     // fire deleted
     $dispatcher->fire('user.deleted', array($userToBeDelete));
     // all good
     return new CommandResult(true, "User successfully deleted.", null, 200);
 }
开发者ID:darryldecode,项目名称:laravelbackend,代码行数:36,代码来源:DeleteUserCommand.php


示例19: handle

 /**
  * @param Navigation $navigation
  * @param Dispatcher $dispatcher
  * @return CommandResult
  */
 public function handle(Navigation $navigation, Dispatcher $dispatcher)
 {
     // check if user has permission
     if (!$this->disablePermissionChecking) {
         if (!$this->user->hasAnyPermission(['navigationBuilder.manage'])) {
             return new CommandResult(false, "Not enough permission.", null, 403);
         }
     }
     // fire before create event
     $dispatcher->fire('navigationBuilder.beforeQuery', array($this->args));
     if ($this->id && $this->id != '') {
         if (!($res = $navigation->with(array())->find($this->id))) {
             return new CommandResult(false, "Navigation does not exist.", null, 404);
         }
     } else {
         if ($this->paginated) {
             $res = $navigation->with(array())->paginate($this->perPage);
         } else {
             $res = $navigation->all();
         }
     }
     // fire after create
     $dispatcher->fire('navigationBuilder.afterQuery', array($this->args));
     // all good
     return new CommandResult(true, "List custom navigation command successful.", $res, 200);
 }
开发者ID:darryldecode,项目名称:laravelbackend,代码行数:31,代码来源:ListCustomNavigationCommand.php


示例20: subscribe

 /**
  * @param Dispatcher $events
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']);
     $events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']);
     $events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']);
     $events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']);
 }
开发者ID:asifalimd,项目名称:core,代码行数:10,代码来源:DiscussionMetadataUpdater.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Foundation\Application类代码示例发布时间:2022-05-23
下一篇:
PHP Encryption\Encrypter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap