X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FDatabase%2FDatabase.php;h=9527fefb0f46310ef2fe49dcab9baa541540361d;hb=acb85feafbc8d493e96db3ffa398c0741ef5561e;hp=032a282030a7b3bdbc1f0a5e892195361ff4f033;hpb=ab6efea9b25f082c93ce7cc4c087002d57041d22;p=friendica.git diff --git a/src/Database/Database.php b/src/Database/Database.php index 032a282030..9527fefb0f 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -55,15 +55,15 @@ class Database /** * @var IManageConfigValues */ - protected $config; + protected $config = null; /** * @var Profiler */ - protected $profiler; + protected $profiler = null; /** * @var LoggerInterface */ - protected $logger; + protected $logger = null; protected $server_info = ''; /** @var PDO|mysqli */ protected $connection; @@ -81,20 +81,36 @@ class Database /** @var ViewDefinition */ protected $viewDefinition; - public function __construct(IManageConfigValues $config, Profiler $profiler, DbaDefinition $dbaDefinition, ViewDefinition $viewDefinition) + public function __construct(IManageConfigValues $config, DbaDefinition $dbaDefinition, ViewDefinition $viewDefinition) { // We are storing these values for being able to perform a reconnect - $this->config = $config; - $this->profiler = $profiler; + $this->config = $config; $this->dbaDefinition = $dbaDefinition; $this->viewDefinition = $viewDefinition; - // Temporary NullLogger until we can fetch the logger class from the config + // Use dummy values - necessary for the first factory call of the logger itself $this->logger = new NullLogger(); + $this->profiler = new Profiler($config); $this->connect(); } + /** + * @param IManageConfigValues $config + * @param Profiler $profiler + * @param LoggerInterface $logger + * + * @return void + * + * @todo Make this method obsolet - use a clean pattern instead ... + */ + public function setDependency(IManageConfigValues $config, Profiler $profiler, LoggerInterface $logger) + { + $this->logger = $logger; + $this->profiler = $profiler; + $this->config = $config; + } + /** * Tries to connect to database * @@ -196,21 +212,6 @@ class Database $this->testmode = $test; } - /** - * Sets the logger for DBA - * - * @note this is necessary because if we want to load the logger configuration - * from the DB, but there's an error, we would print out an exception. - * So the logger gets updated after the logger configuration can be retrieved - * from the database - * - * @param LoggerInterface $logger - */ - public function setLogger(LoggerInterface $logger) - { - $this->logger = $logger; - } - /** * Sets the profiler for DBA *