Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3914907
D234.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D234.diff
View Options
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -6,7 +6,7 @@
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
-use File;
+use Config;
class EventServiceProvider extends ServiceProvider {
@@ -14,12 +14,7 @@
* Registers all our listeners as subscriber classes
*/
private function subscribeListeners () {
- $namespace = Container::getInstance()->getNamespace() . 'Listeners\\';
- $files = File::allFiles(app_path('Listeners'));
- foreach ($files as $file) {
- $class = $namespace . $file->getBasename('.php');
- $this->subscribe[] = $class;
- }
+ $this->subscribe += Config::get('app.listeners');
}
/**
diff --git a/config/app.php b/config/app.php
--- a/config/app.php
+++ b/config/app.php
@@ -180,6 +180,23 @@
/*
|--------------------------------------------------------------------------
+ | Events listeners
+ |--------------------------------------------------------------------------
+ |
+ | The events listeners listed here will be automatically loaded on the
+ | request to your application.
+ |
+ */
+
+ 'listeners' => [
+ Nasqueron\Notifications\Listeners\AMQPEventListener::class,
+ Nasqueron\Notifications\Listeners\LastPayloadSaver::class,
+ Nasqueron\Notifications\Listeners\NotificationListener::class,
+ Nasqueron\Notifications\Listeners\PhabricatorListener::class,
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
diff --git a/tests/Providers/EventServiceProviderTest.php b/tests/Providers/EventServiceProviderTest.php
new file mode 100644
--- /dev/null
+++ b/tests/Providers/EventServiceProviderTest.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Nasqueron\Notifications\Tests\Providers;
+
+use Nasqueron\Notifications\Providers\EventServiceProvider;
+
+use Config;
+use File;
+
+class EventServiceProviderTest extends TestCase {
+
+ public function testType () {
+ $this->assertServiceInstanceOf(
+ 'Illuminate\Contracts\Events\Dispatcher',
+ 'events'
+ );
+ }
+
+ ///
+ /// Tests specific to this service provider
+ ///
+
+ public function testOmittedFiles () {
+ $subscribe = [];
+
+ $namespace = $this->app->getInstance()->getNamespace() . 'Listeners\\';
+ $files = File::allFiles(app_path('Listeners'));
+ foreach ($files as $file) {
+ $class = $namespace . $file->getBasename('.php');
+ $subscribe[] = $class;
+ }
+
+ $this->assertEquals(
+ $subscribe, Config::get('app.listeners'),
+ 'The files in the app/Listeners folder and the array of classes ' .
+ 'defined in config/app.php at listeners key diverge.',
+ 0.0, 10, true // delta, maxDepth, canonicalize
+ );
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 17:42 (18 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2308327
Default Alt Text
D234.diff (3 KB)
Attached To
Mode
D234: Move to config the list of event listeners
Attached
Detach File
Event Timeline
Log In to Comment