mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 14:16:39 +02:00
This commit is contained in:
@@ -119,6 +119,7 @@ class Connection implements IConnection
|
|||||||
{
|
{
|
||||||
if ($this->config['driver'] instanceof Driver) {
|
if ($this->config['driver'] instanceof Driver) {
|
||||||
$this->driver = $this->config['driver'];
|
$this->driver = $this->config['driver'];
|
||||||
|
$this->translator = new Translator($this);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} elseif (is_subclass_of($this->config['driver'], Driver::class)) {
|
} elseif (is_subclass_of($this->config['driver'], Driver::class)) {
|
||||||
@@ -135,6 +136,8 @@ class Connection implements IConnection
|
|||||||
$event = $this->onEvent ? new Event($this, Event::CONNECT) : null;
|
$event = $this->onEvent ? new Event($this, Event::CONNECT) : null;
|
||||||
try {
|
try {
|
||||||
$this->driver = new $class($this->config);
|
$this->driver = new $class($this->config);
|
||||||
|
$this->translator = new Translator($this);
|
||||||
|
|
||||||
if ($event) {
|
if ($event) {
|
||||||
$this->onEvent($event->done());
|
$this->onEvent($event->done());
|
||||||
}
|
}
|
||||||
@@ -160,7 +163,7 @@ class Connection implements IConnection
|
|||||||
{
|
{
|
||||||
if ($this->driver) {
|
if ($this->driver) {
|
||||||
$this->driver->disconnect();
|
$this->driver->disconnect();
|
||||||
$this->driver = null;
|
$this->driver = $this->translator = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,11 +264,7 @@ class Connection implements IConnection
|
|||||||
if (!$this->driver) {
|
if (!$this->driver) {
|
||||||
$this->connect();
|
$this->connect();
|
||||||
}
|
}
|
||||||
if (!$this->translator) {
|
return (clone $this->translator)->translate($args);
|
||||||
$this->translator = new Translator($this);
|
|
||||||
}
|
|
||||||
$translator = clone $this->translator;
|
|
||||||
return $translator->translate($args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user