diff options
Diffstat (limited to 'app/ServiceProvider')
-rw-r--r-- | app/ServiceProvider/DatabaseProvider.php (renamed from app/ServiceProvider/Database.php) | 10 | ||||
-rw-r--r-- | app/ServiceProvider/Event.php | 15 | ||||
-rw-r--r-- | app/ServiceProvider/EventDispatcherProvider.php | 28 | ||||
-rw-r--r-- | app/ServiceProvider/LoggingProvider.php (renamed from app/ServiceProvider/Logging.php) | 2 | ||||
-rw-r--r-- | app/ServiceProvider/MailerProvider.php (renamed from app/ServiceProvider/Mailer.php) | 2 | ||||
-rw-r--r-- | app/ServiceProvider/ModelProvider.php | 63 |
6 files changed, 98 insertions, 22 deletions
diff --git a/app/ServiceProvider/Database.php b/app/ServiceProvider/DatabaseProvider.php index 75e1f73e..fa5319a0 100644 --- a/app/ServiceProvider/Database.php +++ b/app/ServiceProvider/DatabaseProvider.php @@ -4,9 +4,9 @@ namespace ServiceProvider; use Pimple\Container; use Pimple\ServiceProviderInterface; -use PicoDb\Database as Dbal; +use PicoDb\Database; -class Database implements ServiceProviderInterface +class DatabaseProvider implements ServiceProviderInterface { public function register(Container $container) { @@ -55,7 +55,7 @@ class Database implements ServiceProviderInterface { require_once __DIR__.'/../Schema/Sqlite.php'; - return new Dbal(array( + return new Database(array( 'driver' => 'sqlite', 'filename' => DB_FILENAME )); @@ -70,7 +70,7 @@ class Database implements ServiceProviderInterface { require_once __DIR__.'/../Schema/Mysql.php'; - return new Dbal(array( + return new Database(array( 'driver' => 'mysql', 'hostname' => DB_HOSTNAME, 'username' => DB_USERNAME, @@ -89,7 +89,7 @@ class Database implements ServiceProviderInterface { require_once __DIR__.'/../Schema/Postgres.php'; - return new Dbal(array( + return new Database(array( 'driver' => 'postgres', 'hostname' => DB_HOSTNAME, 'username' => DB_USERNAME, diff --git a/app/ServiceProvider/Event.php b/app/ServiceProvider/Event.php deleted file mode 100644 index 0436aa7b..00000000 --- a/app/ServiceProvider/Event.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -namespace ServiceProvider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Core\Event as EventDispatcher; - -class Event implements ServiceProviderInterface -{ - public function register(Container $container) - { - $container['event'] = new EventDispatcher; - } -} diff --git a/app/ServiceProvider/EventDispatcherProvider.php b/app/ServiceProvider/EventDispatcherProvider.php new file mode 100644 index 00000000..90210ba6 --- /dev/null +++ b/app/ServiceProvider/EventDispatcherProvider.php @@ -0,0 +1,28 @@ +<?php + +namespace ServiceProvider; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; +use Subscriber\NotificationSubscriber; +use Subscriber\ProjectActivitySubscriber; +use Subscriber\ProjectDailySummarySubscriber; +use Subscriber\ProjectModificationDateSubscriber; +use Subscriber\WebhookSubscriber; +use Symfony\Component\EventDispatcher\EventDispatcher; + +class EventDispatcherProvider implements ServiceProviderInterface +{ + public function register(Container $container) + { + $container['dispatcher'] = new EventDispatcher; + $container['dispatcher']->addSubscriber(new ProjectActivitySubscriber($container)); + $container['dispatcher']->addSubscriber(new ProjectDailySummarySubscriber($container)); + $container['dispatcher']->addSubscriber(new ProjectModificationDateSubscriber($container)); + $container['dispatcher']->addSubscriber(new WebhookSubscriber($container)); + $container['dispatcher']->addSubscriber(new NotificationSubscriber($container)); + + // Automatic actions + $container['action']->attachEvents(); + } +} diff --git a/app/ServiceProvider/Logging.php b/app/ServiceProvider/LoggingProvider.php index 9737cadc..93f55a9c 100644 --- a/app/ServiceProvider/Logging.php +++ b/app/ServiceProvider/LoggingProvider.php @@ -8,7 +8,7 @@ use Monolog\Logger; use Monolog\Handler\StreamHandler; use Monolog\Handler\SyslogHandler; -class Logging implements ServiceProviderInterface +class LoggingProvider implements ServiceProviderInterface { public function register(Container $container) { diff --git a/app/ServiceProvider/Mailer.php b/app/ServiceProvider/MailerProvider.php index c82c16f6..f6b71363 100644 --- a/app/ServiceProvider/Mailer.php +++ b/app/ServiceProvider/MailerProvider.php @@ -8,7 +8,7 @@ use Swift_SmtpTransport; use Swift_SendmailTransport; use Swift_MailTransport; -class Mailer implements ServiceProviderInterface +class MailerProvider implements ServiceProviderInterface { public function register(Container $container) { diff --git a/app/ServiceProvider/ModelProvider.php b/app/ServiceProvider/ModelProvider.php new file mode 100644 index 00000000..1a940058 --- /dev/null +++ b/app/ServiceProvider/ModelProvider.php @@ -0,0 +1,63 @@ +<?php + +namespace ServiceProvider; + +use Model\Config; +use Model\Project; +use Model\Webhook; +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +class ModelProvider implements ServiceProviderInterface +{ + private $models = array( + 'Acl', + 'Action', + 'Authentication', + 'Board', + 'Category', + 'Color', + 'Comment', + 'Config', + 'DateParser', + 'File', + 'GithubWebhook', + 'LastLogin', + 'Notification', + 'Project', + 'ProjectActivity', + 'ProjectAnalytics', + 'ProjectDailySummary', + 'ProjectPaginator', + 'ProjectPermission', + 'SubTask', + 'SubtaskPaginator', + 'Swimlane', + 'Task', + 'TaskCreation', + 'TaskDuplication', + 'TaskExport', + 'TaskFinder', + 'TaskModification', + 'TaskPaginator', + 'TaskPermission', + 'TaskPosition', + 'TaskStatus', + 'TaskValidator', + 'TimeTracking', + 'User', + 'Webhook', + ); + + public function register(Container $container) + { + foreach ($this->models as $model) { + + $class = '\Model\\'.$model; + + $container[lcfirst($model)] = function ($c) use ($class) { + return new $class($c); + }; + } + } +} |