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


PHP Dispatcher::subscribe方法代码示例

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


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

示例1: boot

 /**
  * Register the application's event listeners.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     foreach ($this->listen as $event => $listeners) {
         foreach ($listeners as $listener) {
             $events->listen($event, $listener);
         }
     }
     foreach ($this->subscribe as $subscriber) {
         $events->subscribe($subscriber);
     }
 }
开发者ID:HarveyCheng,项目名称:myblog,代码行数:17,代码来源:EventServiceProvider.php

示例2: boot

 /**
  * Bootstrap the application events.
  *
  * @param \Illuminate\Contracts\Events\Dispatcher $dispatcher
  * @return void
  */
 public function boot(Dispatcher $dispatcher)
 {
     $this->publishes(array(__DIR__ . '/../../config/notification.php' => config_path('notification.php')), 'config');
     $dispatcher->subscribe('Krucas\\Notification\\Subscriber');
     Blade::directive('notification', function ($container = null) {
         if (strcasecmp('()', $container) === 0) {
             $container = null;
         }
         return "<?php echo app('notification')->container({$container})->show(); ?>";
     });
 }
开发者ID:areyi,项目名称:notification,代码行数:17,代码来源:NotificationServiceProvider.php

示例3: registerListenersAndSubsribers

 private function registerListenersAndSubsribers(DispatcherContract $events)
 {
     foreach ($this->listen as $event => $listeners) {
         foreach ($listeners as $listener) {
             $events->listen($event, $listener);
         }
     }
     foreach ($this->subscribe as $subscriber) {
         $events->subscribe($subscriber);
     }
 }
开发者ID:benepfist,项目名称:laravelbackup,代码行数:11,代码来源:BackupServiceProvider.php

示例4: register

 protected function register()
 {
     foreach ($this->fields as $type => $renderer) {
         $this->renderer->addRenderer($type, $renderer);
     }
     foreach ($this->resources as $type => $resource) {
         $this->renderer->addResource($type, $resource);
     }
     foreach ($this->handlers as $subscriber) {
         $this->events->subscribe($subscriber);
     }
 }
开发者ID:master0mind,项目名称:Lavender,代码行数:12,代码来源:Kernel.php

示例5: boot

 /**
  * Register bindings in the container.
  *
  * @param Dispatcher $events
  *
  * @return void
  */
 public function boot(Dispatcher $events)
 {
     $this->app->booted(function () {
         if (Request::getUser() && Request::getPassword()) {
             return Auth::onceBasic('name');
         }
     });
     $events->listen('auth.login', function ($user) {
         $user->last_login = new Carbon();
         $user->last_ip = Request::getClientIp();
         $user->save();
     });
     /* IRC Notification */
     $events->listen('eloquent.created: Strimoid\\Models\\User', function (User $user) {
         $url = Config::get('app.hubot_url');
         if (!$url) {
             return;
         }
         try {
             Guzzle::post($url, ['json' => ['room' => '#strimoid', 'text' => 'Mamy nowego użytkownika ' . $user->name . '!']]);
         } catch (Exception $e) {
         }
     });
     $events->listen('eloquent.created: Strimoid\\Models\\Entry', function (Entry $entry) {
         $url = Config::get('app.hubot_url');
         if (!$url) {
             return;
         }
         try {
             $text = strip_tags($entry->text);
             $text = trim(preg_replace('/\\s+/', ' ', $text));
             $text = Str::limit($text, 100);
             Guzzle::post($url, ['json' => ['room' => '#strimoid-entries', 'text' => '[' . $entry->group->name . '] ' . $entry->user->name . ': ' . $text]]);
         } catch (Exception $e) {
         }
     });
     $events->subscribe(NewActionHandler::class);
     $events->subscribe(NotificationsHandler::class);
     $events->subscribe(PubSubHandler::class);
 }
开发者ID:vegax87,项目名称:Strimoid,代码行数:47,代码来源:EventsServiceProvider.php

示例6: boot

 /**
  * Register the application's event listeners.
  *
  * @param  Dispatcher $events
  * @return void
  */
 public function boot(Dispatcher $events)
 {
     foreach ($this->listen as $event => $listeners) {
         foreach ($listeners as $key => $listener) {
             if (is_integer($listener)) {
                 $listener = $key;
                 $priority = $listener;
             } else {
                 $priority = 0;
             }
             $events->listen($event, $listener, $priority);
         }
     }
     foreach ($this->subscribe as $subscriber) {
         $events->subscribe($subscriber);
     }
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:23,代码来源:StreamsEventProvider.php

示例7: boot

 /**
  * Perform post-registration booting of services.
  *
  * @return void
  */
 public function boot(Gate $gate, EventDispatcher $event)
 {
     $event->subscribe('Lembarek\\Blog\\Listeners\\IncreasePostPopularity');
     $event->listen('Lembarek\\Blog\\Events\\PostHasViewed', 'Lembarek\\Blog\\Listeners\\IncreasePostViews');
     $this->fullBoot('blog', __DIR__ . '/../');
 }
开发者ID:lembarek,项目名称:blog,代码行数:11,代码来源:BlogServiceProvider.php

示例8: registerSubscribers

 /**
  * Register the package subscribers
  *
  * @param DispatcherContract $events
  */
 public function registerSubscribers(DispatcherContract $events)
 {
     foreach ($this->subscribers() as $subscriber) {
         $events->subscribe($subscriber);
     }
 }
开发者ID:mightystudios,项目名称:trust,代码行数:11,代码来源:TrustServiceProvider.php

示例9: boot

 /**
  * @param \Illuminate\Contracts\Events\Dispatcher $events
  */
 public function boot(Dispatcher $events)
 {
     $events->subscribe(CacheSubscriber::class);
 }
开发者ID:bjrnblm,项目名称:blender,代码行数:7,代码来源:RepositoryServiceProvider.php


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