當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Event::subscribe方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Facades\Event::subscribe方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::subscribe方法的具體用法?PHP Event::subscribe怎麽用?PHP Event::subscribe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Facades\Event的用法示例。


在下文中一共展示了Event::subscribe方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: boot

 public function boot(Guard $guard, MixPanel $mixPanel)
 {
     include __DIR__ . '/Http/routes.php';
     $this->app->make(config('auth.model'))->observe(new MixPanelUserObserver($mixPanel));
     $eventHandler = new MixPanelEventHandler($guard, $mixPanel);
     Event::subscribe($eventHandler);
 }
開發者ID:janusnic,項目名稱:MixPanel,代碼行數:7,代碼來源:MixPanelServiceProvider.php

示例2: boot

 public function boot(Request $request, Guard $guard, LaravelMixpanel $mixPanel)
 {
     include __DIR__ . '/../Http/routes.php';
     $this->app->make(config('auth.model'))->observe(new LaravelMixpanelUserObserver($request, $mixPanel));
     $eventHandler = new LaravelMixpanelEventHandler($request, $guard, $mixPanel);
     Event::subscribe($eventHandler);
 }
開發者ID:emergingdzns,項目名稱:laravel-mixpanel,代碼行數:7,代碼來源:LaravelMixpanelServiceProvider.php

示例3: boot

 /**
  * Register the application's event listeners.
  *
  * @return void
  */
 public function boot()
 {
     $add_hook = function ($type, $name, $listeners) {
         $listeners = is_array($listeners) ? $listeners : [$listeners];
         array_walk($listeners, function ($listener) use($type, $name) {
             $fn = 'add_' . $type;
             // `add_action` or `add_filter`
             $fn($name, function () use($listener) {
                 $listener_instance = app()->make($listener);
                 return call_user_func_array([$listener_instance, 'handle'], func_get_args());
             }, 10, 10);
         });
     };
     foreach ($this->listens() as $event => $listeners) {
         $listeners = is_array($listeners) ? $listeners : [$listeners];
         foreach ($listeners as $listener) {
             Event::listen($event, $listener);
         }
     }
     foreach ($this->subscribe as $subscriber) {
         Event::subscribe($subscriber);
     }
     foreach ($this->action as $action => $listeners) {
         $add_hook('action', $action, $listeners);
     }
     foreach ($this->filter as $filter => $listeners) {
         $add_hook('filter', $filter, $listeners);
     }
 }
開發者ID:laraish,項目名稱:framework,代碼行數:34,代碼來源:EventServiceProvider.php

示例4: register

 public function register()
 {
     Version::addPrefixUserAgentSegment('Laravel integration', '1.7.0');
     Version::addSuffixUserAgentSegment('PHP', phpversion());
     $laravel = app();
     Version::addSuffixUserAgentSegment('Laravel', $laravel::VERSION);
     $this->registerManager();
     Event::subscribe('\\AlgoliaSearch\\Laravel\\EloquentSubscriber');
 }
開發者ID:algolia,項目名稱:algoliasearch-laravel,代碼行數:9,代碼來源:AlgoliaServiceProvider.php

示例5: boot

 /**
  * Register the application's event listeners.
  *
  * @return void
  */
 public function boot()
 {
     foreach ($this->listens() as $event => $listeners) {
         foreach ($listeners as $listener) {
             Event::listen($event, $listener);
         }
     }
     foreach ($this->subscribe as $subscriber) {
         Event::subscribe($subscriber);
     }
 }
開發者ID:davidhemphill,項目名稱:framework,代碼行數:16,代碼來源:EventServiceProvider.php

示例6: boot

 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     Event::subscribe('App\\Listeners\\Events\\AuthHistoryLogger');
     Event::subscribe('App\\Listeners\\Events\\UserHistoryLogger');
     Project::observe($this->app->make('App\\Events\\Observer\\ProjectObserver'));
     Entry::observe($this->app->make('App\\Events\\Observer\\EntryObserver'));
     Share::observe($this->app->make('App\\Events\\Observer\\ShareObserver'));
     Team::observe($this->app->make('App\\Events\\Observer\\TeamObserver'));
     EntryTag::observe($this->app->make('App\\Events\\Observer\\EntryTagObserver'));
     EntryTeam::observe($this->app->make('App\\Events\\Observer\\EntryTeamObserver'));
     ProjectTeam::observe($this->app->make('App\\Events\\Observer\\ProjectTeamObserver'));
     UserTeam::observe($this->app->make('App\\Events\\Observer\\UserTeamObserver'));
 }
開發者ID:vaidasm,項目名稱:vault,代碼行數:20,代碼來源:EventServiceProvider.php

示例7: boot

 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     Event::subscribe('App\\Handlers\\Events\\AuthListener');
     parent::boot($events);
     //
 }
開發者ID:sotoplatero,項目名稱:lacallemonte,代碼行數:12,代碼來源:EventServiceProvider.php

示例8: registerEvents

 /**
  * Register the application's event listeners.
  *
  * @return void
  */
 public function registerEvents()
 {
     foreach ($this->events as $event => $listeners) {
         foreach ($listeners as $listener) {
             Event::listen($event, $listener);
         }
     }
     foreach ($this->subscribe as $subscriber) {
         Event::subscribe($subscriber);
     }
 }
開發者ID:cornex,項目名稱:forumia,代碼行數:16,代碼來源:AggregateServiceProvider.php

示例9: register

 public function register()
 {
     Event::subscribe('\\AlgoliaSearch\\Laravel\\EloquentSubscriber');
 }
開發者ID:crgriggs,項目名稱:fishark,代碼行數:4,代碼來源:AlgoliaServiceProvider.php

示例10: __construct

 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function __construct()
 {
     $subscriber = new SystemListern();
     Event::subscribe($subscriber);
     //$this->middleware('auth');
 }
開發者ID:a-suvorov,項目名稱:medschedule,代碼行數:11,代碼來源:HomeController.php

示例11: boot

 /**
  * {@inheritDoc}
  */
 public function boot()
 {
     // Handle locations upon login
     $this->registerLocation();
     // Register timezone settings
     date_default_timezone_set(Settings::get('timezone', Config::get('app.timezone')));
     // Register ServiceProviders
     App::register('DMA\\Friends\\FriendsServiceProvider');
     App::register('Maatwebsite\\Excel\\ExcelServiceProvider');
     // Register aliases
     $alias = AliasLoader::getInstance();
     $alias->alias('Excel', 'Maatwebsite\\Excel\\Facades\\Excel');
     // Register Event Subscribers
     $subscriber = new FriendsEventHandler();
     Event::subscribe($subscriber);
     // Bind user and point events to trigger user synchronization with MailChimp
     MailChimpIntegration::bindEvents();
     // Generate barcode_id when a user object is created
     // TODO: Migrate when user plugin is forked
     User::creating(function ($user) {
         if (empty($user->barcode_id)) {
             $user->barcode_id = substr(md5($user->email), 0, 9);
         }
     });
     // Extend the user model to support our custom metadata
     User::extend(function ($model) {
         $model->hasOne['metadata'] = ['DMA\\Friends\\Models\\Usermeta', 'key' => 'user_id'];
         $model->hasMany['activityLogs'] = ['DMA\\Friends\\Models\\ActivityLog'];
         $model->hasMany['bookmarks'] = ['DMA\\Friends\\Models\\Bookmark'];
         $model->hasMany['notifications'] = ['DMA\\Friends\\Models\\Notification'];
         $model->hasMany['rates'] = ['DMA\\Friends\\Models\\UserRate'];
         $model->belongsToMany['activities'] = ['DMA\\Friends\\Models\\Activity', 'table' => 'dma_friends_activity_user', 'user_id', 'activity_id', 'timestamps' => true, 'order' => 'dma_friends_activity_user.created_at desc'];
         $model->belongsToMany['steps'] = ['DMA\\Friends\\Models\\Step', 'table' => 'dma_friends_step_user', 'user_id', 'step_id', 'timestamps' => true, 'order' => 'dma_friends_step_user.created_at desc'];
         $model->belongsToMany['badges'] = ['DMA\\Friends\\Models\\Badge', 'table' => 'dma_friends_badge_user', 'user_id', 'badge_id', 'timestamps' => true, 'order' => 'dma_friends_badge_user.created_at desc'];
         $model->belongsToMany['rewards'] = ['DMA\\Friends\\Models\\Reward', 'table' => 'dma_friends_reward_user', 'user_id', 'reward_id', 'timestamps' => true, 'order' => 'dma_friends_reward_user.created_at desc'];
         $model->belongsToMany['groups'] = ['DMA\\Friends\\Models\\UserGroup', 'table' => 'dma_friends_users_groups', 'key' => 'user_id', 'foreignKey' => 'group_id', 'pivot' => ['membership_status']];
     });
     // Extend User fields
     $context = $this;
     Event::listen('backend.form.extendFields', function ($widget) use($context) {
         $context->extendedUserFields($widget);
         $context->extendedSettingFields($widget);
     });
     Event::listen('backend.list.extendColumns', function ($widget) {
         if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
             return;
         }
         $widget->addColumns(['barcode_id' => ['label' => 'Barcode ID'], 'full_name' => ['label' => 'Full Name', 'relation' => 'metadata', 'sortable' => false, 'select' => "concat(first_name, ' ', last_name)", 'searchable' => true], 'first_name' => ['label' => 'First Name', 'relation' => 'metadata', 'select' => '@first_name', 'searchable' => true], 'last_name' => ['label' => 'Last Name', 'relation' => 'metadata', 'select' => '@last_name', 'searchable' => true], 'points' => ['label' => 'Points'], 'zip' => ['label' => 'Zip'], 'current_member_number' => ['label' => 'Membership ID', 'relation' => 'metadata', 'select' => '@current_member_number']]);
     });
 }
開發者ID:janusnic,項目名稱:OctoberFriends,代碼行數:53,代碼來源:Plugin.php

示例12: function

<?php

use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Session;
// User Login event
Event::listen('user.login', function ($userId, $email) {
    Session::put('userId', $userId);
    Session::put('email', $email);
});
// User logout event
Event::listen('user.logout', function () {
    Session::flush();
});
// Subscribe to User Mailer events
Event::subscribe('Edgji\\Sentrystart\\Mailers\\UserMailer');
開發者ID:edgji,項目名稱:sentrystart,代碼行數:15,代碼來源:observables.php

示例13: registerAuthenticationEventHandler

 private function registerAuthenticationEventHandler()
 {
     Event::subscribe('Hamedmehryar\\SessionTracker\\AuthenticationHandler');
 }
開發者ID:hamedmehryar,項目名稱:laravel-session-tracker,代碼行數:4,代碼來源:SessionTrackerServiceProvider.php

示例14: register

 public function register()
 {
     $this->registerManager();
     Event::subscribe('\\AlgoliaSearch\\Laravel\\EloquentSubscriber');
 }
開發者ID:Nikita240,項目名稱:algoliasearch-laravel,代碼行數:5,代碼來源:AlgoliaServiceProvider.php

示例15: defineListeners

 public function defineListeners()
 {
     Event::subscribe(new RagnarokListener());
 }
開發者ID:alfredoem,項目名稱:ragnarok,代碼行數:4,代碼來源:RagnarokServiceProvider.php


注:本文中的Illuminate\Support\Facades\Event::subscribe方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。