本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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');
}
示例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);
}
}
示例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'));
}
示例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);
//
}
示例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);
}
}
示例9: register
public function register()
{
Event::subscribe('\\AlgoliaSearch\\Laravel\\EloquentSubscriber');
}
示例10: __construct
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$subscriber = new SystemListern();
Event::subscribe($subscriber);
//$this->middleware('auth');
}
示例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']]);
});
}
示例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');
示例13: registerAuthenticationEventHandler
private function registerAuthenticationEventHandler()
{
Event::subscribe('Hamedmehryar\\SessionTracker\\AuthenticationHandler');
}
示例14: register
public function register()
{
$this->registerManager();
Event::subscribe('\\AlgoliaSearch\\Laravel\\EloquentSubscriber');
}
示例15: defineListeners
public function defineListeners()
{
Event::subscribe(new RagnarokListener());
}