mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 06:03:39 +08:00
New listen API
Event subscriptions now take place before *any* boot method is called. This ensures that all event listeners are registered before things happen – e.g. locales are registered before the translator is instantiated in the Tags extension's boot method.
This commit is contained in:
parent
6db682217a
commit
0a19ca5e19
|
@ -1,6 +1,7 @@
|
||||||
<?php namespace Flarum\Support;
|
<?php namespace Flarum\Support;
|
||||||
|
|
||||||
use Flarum\Support\ServiceProvider;
|
use Flarum\Support\ServiceProvider;
|
||||||
|
use Illuminate\Events\Dispatcher;
|
||||||
|
|
||||||
class Extension extends ServiceProvider
|
class Extension extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
@ -11,4 +12,8 @@ class Extension extends ServiceProvider
|
||||||
public function uninstall()
|
public function uninstall()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function listen(Dispatcher $events)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,5 +21,11 @@ class ExtensionsServiceProvider extends ServiceProvider
|
||||||
$providers[$extension] = $this->app->register($providerName);
|
$providers[$extension] = $this->app->register($providerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$events = $this->app->make('events');
|
||||||
|
|
||||||
|
foreach ($providers as $provider) {
|
||||||
|
$provider->listen($events);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,23 +5,8 @@ use Illuminate\Events\Dispatcher;
|
||||||
|
|
||||||
class Extension extends BaseExtension
|
class Extension extends BaseExtension
|
||||||
{
|
{
|
||||||
/**
|
public function listen(Dispatcher $events)
|
||||||
* Bootstrap the application events.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function boot(Dispatcher $events)
|
|
||||||
{
|
{
|
||||||
$events->subscribe('{{namespace}}\Listeners\AddClientAssets');
|
$events->subscribe('{{namespace}}\Listeners\AddClientAssets');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the service provider.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function register()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user