Move events handling to Symfony\EventDispatcher
This commit is contained in:
@@ -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,
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
28
app/ServiceProvider/EventDispatcherProvider.php
Normal file
28
app/ServiceProvider/EventDispatcherProvider.php
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
@@ -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)
|
||||
{
|
||||
63
app/ServiceProvider/ModelProvider.php
Normal file
63
app/ServiceProvider/ModelProvider.php
Normal file
@@ -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);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user