Use Pimple instead of Core\Registry and add Monolog for logging
This commit is contained in:
@@ -264,7 +264,7 @@ class Action extends Base
|
||||
public function load($name, $project_id, $event)
|
||||
{
|
||||
$className = '\Action\\'.$name;
|
||||
return new $className($this->registry, $project_id, $event);
|
||||
return new $className($this->container, $project_id, $event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,12 +24,12 @@ class Authentication extends Base
|
||||
*/
|
||||
public function backend($name)
|
||||
{
|
||||
if (! isset($this->registry->$name)) {
|
||||
if (! isset($this->container[$name])) {
|
||||
$class = '\Auth\\'.ucfirst($name);
|
||||
$this->registry->$name = new $class($this->registry);
|
||||
$this->container[$name] = new $class($this->container);
|
||||
}
|
||||
|
||||
return $this->registry->shared($name);
|
||||
return $this->container[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Model;
|
||||
|
||||
use Core\Event;
|
||||
use Core\Tool;
|
||||
use Core\Registry;
|
||||
use Pimple\Container;
|
||||
use PicoDb\Database;
|
||||
|
||||
/**
|
||||
@@ -58,24 +58,24 @@ abstract class Base
|
||||
public $event;
|
||||
|
||||
/**
|
||||
* Registry instance
|
||||
* Container instance
|
||||
*
|
||||
* @access protected
|
||||
* @var \Core\Registry
|
||||
* @var Pimple\Container
|
||||
*/
|
||||
protected $registry;
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param \Core\Registry $registry Registry instance
|
||||
* @param Pimple\Container $container
|
||||
*/
|
||||
public function __construct(Registry $registry)
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
$this->db = $this->registry->shared('db');
|
||||
$this->event = $this->registry->shared('event');
|
||||
$this->container = $container;
|
||||
$this->db = $this->container['db'];
|
||||
$this->event = $this->container['event'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ abstract class Base
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
return Tool::loadModel($this->registry, $name);
|
||||
return Tool::loadModel($this->container, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -117,7 +117,7 @@ class Notification extends Base
|
||||
|
||||
foreach ($events as $event_name => $template_name) {
|
||||
|
||||
$listener = new NotificationListener($this->registry);
|
||||
$listener = new NotificationListener($this->container);
|
||||
$listener->setTemplate($template_name);
|
||||
|
||||
$this->event->attach($event_name, $listener);
|
||||
@@ -135,8 +135,7 @@ class Notification extends Base
|
||||
public function sendEmails($template, array $users, array $data)
|
||||
{
|
||||
try {
|
||||
$transport = $this->registry->shared('mailer');
|
||||
$mailer = Swift_Mailer::newInstance($transport);
|
||||
$mailer = Swift_Mailer::newInstance($this->container['mailer']);
|
||||
|
||||
$message = Swift_Message::newInstance()
|
||||
->setSubject($this->getMailSubject($template, $data))
|
||||
@@ -149,7 +148,7 @@ class Notification extends Base
|
||||
}
|
||||
}
|
||||
catch (Swift_TransportException $e) {
|
||||
debug($e->getMessage());
|
||||
$this->container['logger']->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -546,7 +546,7 @@ class Project extends Base
|
||||
GithubWebhook::EVENT_COMMIT,
|
||||
);
|
||||
|
||||
$listener = new ProjectModificationDateListener($this->registry);
|
||||
$listener = new ProjectModificationDateListener($this->container);
|
||||
|
||||
foreach ($events as $event_name) {
|
||||
$this->event->attach($event_name, $listener);
|
||||
|
||||
@@ -147,7 +147,7 @@ class ProjectActivity extends Base
|
||||
SubTask::EVENT_CREATE,
|
||||
);
|
||||
|
||||
$listener = new ProjectActivityListener($this->registry);
|
||||
$listener = new ProjectActivityListener($this->container);
|
||||
|
||||
foreach ($events as $event_name) {
|
||||
$this->event->attach($event_name, $listener);
|
||||
|
||||
@@ -93,7 +93,7 @@ class Webhook extends Base
|
||||
Task::EVENT_ASSIGNEE_CHANGE,
|
||||
);
|
||||
|
||||
$listener = new WebhookListener($this->registry);
|
||||
$listener = new WebhookListener($this->container);
|
||||
$listener->setUrl($this->url_task_modification);
|
||||
|
||||
foreach ($events as $event_name) {
|
||||
@@ -108,7 +108,7 @@ class Webhook extends Base
|
||||
*/
|
||||
public function attachCreateEvents()
|
||||
{
|
||||
$listener = new WebhookListener($this->registry);
|
||||
$listener = new WebhookListener($this->container);
|
||||
$listener->setUrl($this->url_task_creation);
|
||||
|
||||
$this->event->attach(Task::EVENT_CREATE, $listener);
|
||||
|
||||
Reference in New Issue
Block a user