本文整理汇总了PHP中Illuminate\Foundation\Support\Providers\EventServiceProvider类的典型用法代码示例。如果您正苦于以下问题:PHP EventServiceProvider类的具体用法?PHP EventServiceProvider怎么用?PHP EventServiceProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventServiceProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
User::deleting(function ($user) {
\Event::fire(new UserWasDeleted($user->id));
});
}
开发者ID:Rotron,项目名称:laravel5-shop,代码行数:13,代码来源:EventServiceProvider.php
示例2: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
$events->listen('auth.login', 'Ruysu\\Core\\Listeners\\AuthListener@onLogin');
$events->listen('Ruysu\\Core\\Events\\Auth\\UserRegistered', 'Ruysu\\Core\\Listeners\\AuthListener@onRegister');
$events->listen('Ruysu\\Core\\Events\\Auth\\UserActivated', 'Ruysu\\Core\\Listeners\\AuthListener@onActivate');
}
开发者ID:ruysu,项目名称:laravel-core,代码行数:13,代码来源:EventServiceProvider.php
示例3: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
Project::observe(new SlugGeneratorObserver());
Category::observe(new SlugGeneratorObserver());
Tag::observe(new SlugGeneratorObserver());
}
开发者ID:reiniersb87,项目名称:website,代码行数:13,代码来源:EventServiceProvider.php
示例4: 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::listen('Aacotroneo\\Saml2\\Events\\Saml2LoginEvent', function (Saml2LoginEvent $event) {
$user = $event->getSaml2User();
/*$userData = [
'id' => $user->getUserId(),
'attributes' => $user->getAttributes(),
'assertion' => $user->getRawSamlAssertion()
];*/
$laravelUser = User::where("username", "=", $user->getUserId())->get()->first();
if ($laravelUser != null) {
Auth::login($laravelUser);
} else {
//if first user then create it and login
$count = \App\User::all()->count();
if ($count == 0) {
$data = array();
$data['lastname'] = "";
$data['firstname'] = "";
$data['username'] = $user->getUserId();
$data['role'] = "admin";
$user = \App\User::create($data);
\Auth::login($user);
return \Redirect::to('/');
} else {
abort(401);
}
}
//if it does not exist create it and go on or show an error message
});
}
开发者ID:ghyster,项目名称:dns-angular,代码行数:38,代码来源:EventServiceProvider.php
示例5: boot
public function boot()
{
// DispatcherContract $events
// $events
parent::boot();
//
}
开发者ID:Dreamerpro,项目名称:thinkmerit.api,代码行数:7,代码来源: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);
$this->registerDeleteEvents();
$this->registerCreateEvents();
BudgetLimit::saved(function (BudgetLimit $budgetLimit) {
$end = Navigation::addPeriod(clone $budgetLimit->startdate, $budgetLimit->repeat_freq, 0);
$end->subDay();
$set = $budgetLimit->limitrepetitions()->where('startdate', $budgetLimit->startdate->format('Y-m-d 00:00:00'))->where('enddate', $end->format('Y-m-d 00:00:00'))->get();
if ($set->count() == 0) {
$repetition = new LimitRepetition();
$repetition->startdate = $budgetLimit->startdate;
$repetition->enddate = $end;
$repetition->amount = $budgetLimit->amount;
$repetition->budgetLimit()->associate($budgetLimit);
try {
$repetition->save();
} catch (QueryException $e) {
Log::error('Trying to save new LimitRepetition failed: ' . $e->getMessage());
// @codeCoverageIgnore
}
} else {
if ($set->count() == 1) {
$repetition = $set->first();
$repetition->amount = $budgetLimit->amount;
$repetition->save();
}
}
});
}
开发者ID:webenhanced,项目名称:firefly-iii,代码行数:37,代码来源:EventServiceProvider.php
示例7: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
if (!$this->isLumen()) {
$this->publishes([$this->getConfigPath() => $this->app->make('path.config') . '/viewpresenter.php'], 'config');
}
}
开发者ID:neondigital,项目名称:laravel-view-presenter,代码行数:13,代码来源:ViewPresenterServiceProvider.php
示例8: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
if (!\Request::isMethod('GET')) {
$events->subscribe(PushNotificationHandler::class);
}
}
开发者ID:adminrt,项目名称:phphub-server,代码行数:12,代码来源:EventServiceProvider.php
示例9: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
User::creating(function ($user) {
//
});
}
开发者ID:ChenPeiyuan,项目名称:student-infomation-manager,代码行数:13,代码来源:EventServiceProvider.php
示例10: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
AttributeType::deleting(function ($attr) {
$sub_attrs = Attribute::where('type_id', '=', $attr->id)->get();
foreach ($sub_attrs as $sa) {
$sa->delete();
}
});
EntityType::deleting(function ($entity) {
$entities = $entity->entities;
foreach ($entities as $e) {
$e->delete();
}
});
Entity::deleting(function ($entity) {
$alarms = $entity->alarms;
foreach ($alarms as $a) {
$a->delete();
}
});
Alarm::deleting(function ($alarm) {
$reminders = $alarm->history;
foreach ($reminders as $r) {
$r->delete();
}
});
}
开发者ID:OfficineDigitali,项目名称:pendola,代码行数:34,代码来源:EventServiceProvider.php
示例11: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
$events->listen('eloquent.saving: *', function ($model) {
\File::append('audit', "Table {$model->getTable()} has been saved." . PHP_EOL);
});
}
开发者ID:threening,项目名称:laraseda,代码行数:13,代码来源:EventServiceProvider.php
示例12: 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::listen('language.change', function (Language $language) {
// Change application language
$language->apply()->remember();
// Update user's language
if ($user = Auth::user()) {
$user->language()->associate($language)->save();
}
// Feedback
Session::flash('success', sprintf(_('Language changed to %s'), $language->native_name));
});
Event::listen('auth.login', function (User $user) {
// Change application language to current user's language
if ($user->language instanceof Language) {
$user->language->apply()->remember();
}
// Stats
$user->increment('login_count');
$user->provider->increment('login_count');
// Feedback
Session::flash('success', sprintf(_('Logged in as %s'), $user));
});
Event::listen('auth.logout', function (User $user) {
// Feedback
Session::flash('success', _('Logged out'));
// Reset default application language
Language::forget();
});
}
开发者ID:superdol,项目名称:Wiki,代码行数:37,代码来源:EventServiceProvider.php
示例13: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
Form::component('bsText', 'shared.components.text', ['name', 'label', 'required' => false, 'unit' => false, 'inputCol' => 4]);
Form::component('bsNumber', 'shared.components.number', ['name', 'label', 'required' => false, 'unit' => false, 'inputCol' => 4]);
Form::component('bsTextarea', 'shared.components.textarea', ['name', 'label', 'required' => false, 'rows' => 4]);
Form::component('bsSelect', 'shared.components.select', ['name', 'label', 'choice', 'required' => false, 'unit' => false, 'inputCol' => 4]);
Form::component('twoSelect', 'shared.components.twoSelect', ['label', 'nameA', 'choiceA', 'requiredA' => false, 'unitA' => false, 'nameB', 'choiceB', 'requiredB' => false, 'unitB' => false]);
Form::component('bsDate', 'shared.components.date', ['name', 'label', 'required' => false]);
/**
* Sugar components
*/
// playList must Laravel Collection object
Form::component('playList', 'shared.sugar.playList', ['name', 'playList']);
Form::component('basin', 'shared.sugar.basin', ['name']);
Form::component('province', 'shared.sugar.province', ['name']);
Form::component('clarified', 'shared.sugar.clarified', ['name']);
Form::component('analogTo', 'shared.sugar.analogTo', ['name']);
Form::component('analogDistance', 'shared.sugar.analogDistance', ['name']);
Form::component('shore', 'shared.sugar.shore', ['name']);
Form::component('terrain', 'shared.sugar.terrain', ['name']);
Form::component('nearbyField', 'shared.sugar.nearbyField', ['name']);
Form::component('nearbyInfra', 'shared.sugar.nearbyInfra', ['name']);
Form::component('remark', 'shared.sugar.remark', ['name', 'required' => false]);
Form::component('lateMethod', 'shared.sugar.lateMethod', ['name']);
Form::component('seismicImage', 'shared.sugar.seismicImage', ['name']);
Form::component('latitude', 'shared.sugar.latitude', ['name', 'required' => true]);
Form::component('longitude', 'shared.sugar.longitude', ['name', 'required' => true]);
Form::component('survey', 'shared.sugar.survey', ['name' => 'survey', 'choice']);
}
开发者ID:b813813,项目名称:harleen,代码行数:36,代码来源:EventServiceProvider.php
示例14: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
$events->listen('auth.logout', function ($event) {
Session::flush();
});
}
开发者ID:sanderdekroon,项目名称:yourfoodbox,代码行数:13,代码来源:EventServiceProvider.php
示例15: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
User::creating(function ($user) {
$user->ip_address = Request::ip();
$user->confirmation_code = str_random(60);
$user->referral_code = str_random(10);
$user->referral_secret = str_random(10);
Session::put(Config::get('prelaunch.session:referral_secret'), $user->referral_secret);
});
User::created(function ($user) {
$user->sendConfirmation();
});
# query logger
if (App::environment('local')) {
Event::listen('illuminate.query', function ($sql, $bindings, $time) {
for ($i = 0; $i < sizeof($bindings); $i++) {
if ($bindings[$i] instanceof DateTime) {
$bindings[$i] = $bindings[$i]->getTimestamp();
}
}
Log::info(sprintf("%s (%s) : %s", $sql, implode(",", $bindings), $time));
});
}
}
开发者ID:yizhihou2,项目名称:prelaunchr-laravel,代码行数:31,代码来源:EventServiceProvider.php
示例16: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
$events->listen('mailer.sending', function ($message) {
debug('Email sent "' . $message->getSubject() . '" to "' . array_keys($message->getTo())[0] . '".', ['message' => $message->toString()]);
});
}
开发者ID:hughfletcher,项目名称:nuticket,代码行数:13,代码来源:EventServiceProvider.php
示例17: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
$events->listen('mailer.sending', function ($message) {
// for debugging
});
}
开发者ID:4unkur,项目名称:college-website,代码行数:13,代码来源:EventServiceProvider.php
示例18: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
Contact::updating(function (Contact $contact) {
if ($new_values = $contact->getDirty()) {
if (isset($new_values['status'])) {
$message = \Lang::get('contact.status_update.' . $new_values['status']);
if ($contact->hasAttribute('change_status_comment')) {
if ($comment = $contact->getAttribute('change_status_comment')) {
$message .= PHP_EOL . $comment;
}
unset($contact->change_status_comment);
}
} else {
$values = [];
$old_values = $contact->getOriginal();
foreach ($new_values as $key => $value) {
$values[] = [$key, $old_values[$key], $value];
}
$message = 'json:' . json_encode($values);
}
$log = new ContactLog();
$log->contact_id = $contact->id;
$log->user_id = \Auth::getUser()->id;
$log->comment = $message;
$log->save();
}
});
}
开发者ID:errogaht,项目名称:bv-table,代码行数:35,代码来源:EventServiceProvider.php
示例19: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
*
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
$response = new ResponseBuilder(new JsonResponse());
/*
|--------------------------------------------------------------------------
| Events
|--------------------------------------------------------------------------
|
| These are events used to return custom JSON response when error occurs
| using JWT Library. This type of event listening is compatible with
| Laravel 4.* that JWT Library currently supports.
|
*/
Event::listen('tymon.jwt.invalid', function ($exception) {
throw $exception;
});
Event::listen('tymon.jwt.expired', function ($exception) {
throw $exception;
});
Event::listen('tymon.jwt.absent', function () use($response) {
$exception = new TokenAbsentException();
return $response->exception($exception);
});
Event::listen('tymon.jwt.user_not_found', function () use($response) {
$exception = new TokenInvalidException();
return $response->exception($exception);
});
}
开发者ID:Virgeto,项目名称:GG-enginering-backend,代码行数:36,代码来源:EventServiceProvider.php
示例20: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
Feedback::created(function ($item) {
Cache::tags('feedbacks')->flush();
$this->dispatch(new SentenceProcessing($item));
});
Feedback::updated(function ($item) {
Cache::tags('feedbacks')->flush();
});
Feedback::deleted(function ($item) {
Cache::tags('feedbacks')->flush();
});
Comment::saved(function ($item) {
Cache::tags('comments')->flush();
});
Comment::saved(function ($item) {
Cache::tags('comments')->flush();
});
Sentence::saved(function ($item) {
if ($item->feedback) {
$item->feedback->calculateProbabilities();
}
});
}
开发者ID:uethackathon,项目名称:uethackathon2015_team13,代码行数:31,代码来源:EventServiceProvider.php
注:本文中的Illuminate\Foundation\Support\Providers\EventServiceProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论