本文整理汇总了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);
}
}
示例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(); ?>";
});
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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__ . '/../');
}
示例8: registerSubscribers
/**
* Register the package subscribers
*
* @param DispatcherContract $events
*/
public function registerSubscribers(DispatcherContract $events)
{
foreach ($this->subscribers() as $subscriber) {
$events->subscribe($subscriber);
}
}
示例9: boot
/**
* @param \Illuminate\Contracts\Events\Dispatcher $events
*/
public function boot(Dispatcher $events)
{
$events->subscribe(CacheSubscriber::class);
}