From 6ed63d591f735f4f53a3bd1758286031b5337ae7 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Mon, 2 Apr 2018 23:25:05 +0200 Subject: [PATCH] move app/plugins to app/listeners and give them the App\Listener namespace. --- app/config/conf.app.yml | 2 +- app/config/loader.php | 12 +++--------- app/config/services.php | 7 +++++-- .../AclPlugin.php => listeners/AclListener.php} | 5 ++++- .../DispatchListener.php} | 6 ++++-- 5 files changed, 17 insertions(+), 15 deletions(-) rename app/{plugins/AclPlugin.php => listeners/AclListener.php} (94%) rename app/{plugins/ExceptionHandlerPlugin.php => listeners/DispatchListener.php} (93%) diff --git a/app/config/conf.app.yml b/app/config/conf.app.yml index e5eb185..d2f073e 100644 --- a/app/config/conf.app.yml +++ b/app/config/conf.app.yml @@ -4,7 +4,7 @@ application: modelsDir : ../app/models/ migrationsDir : ../app/migrations/ viewsDir : ../app/views/ - pluginsDir : ../app/plugins/ + listenersDir : ../app/listeners/ libraryDir : ../app/library/ formsDir : ../app/forms/ logDir : ../cache/log/ diff --git a/app/config/loader.php b/app/config/loader.php index c52f34e..b4d6d8a 100644 --- a/app/config/loader.php +++ b/app/config/loader.php @@ -2,20 +2,14 @@ $loader = new \Phalcon\Loader(); -/** - * We're a registering a set of directories taken from the configuration file - */ -$loader->registerDirs( - array( - $config->application->pluginsDir - ) -)->register(); - $loader->registerNamespaces(array( 'App\Controller' => $config->application->controllersDir, + 'App\Listener' => $config->application->listenersDir, 'Model' => $config->application->modelsDir, 'Form' => $config->application->formsDir, 'Httpcb' => $config->application->libraryDir, )); +$loader->register(); + require_once __DIR__ . '/../../vendor/autoload.php'; diff --git a/app/config/services.php b/app/config/services.php index 0822b96..c9112e9 100644 --- a/app/config/services.php +++ b/app/config/services.php @@ -29,6 +29,9 @@ use Httpcb\Auth, Httpcb\Navigation, Httpcb\Menu; +use App\Listener\AclListener, + App\Listener\DispatchListener; + /** * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework */ @@ -54,10 +57,10 @@ $di->setShared('dispatcher', function() use ($di, $config) { }); if ($config->application->debug == false) { - $eventsManager->attach('dispatch:beforeException', new \ExceptionHandlerPlugin()); + $eventsManager->attach('dispatch:beforeException', new DispatchListener()); } - $eventsManager->attach('dispatch:beforeExecuteRoute', new \AclPlugin()); + $eventsManager->attach('dispatch:beforeExecuteRoute', new AclListener()); $dispatcher = new \Phalcon\Mvc\Dispatcher(); $dispatcher->setEventsManager($eventsManager); diff --git a/app/plugins/AclPlugin.php b/app/listeners/AclListener.php similarity index 94% rename from app/plugins/AclPlugin.php rename to app/listeners/AclListener.php index 73c3363..c1ed26b 100644 --- a/app/plugins/AclPlugin.php +++ b/app/listeners/AclListener.php @@ -1,11 +1,14 @@ 'error',