registered Nilemin\Virtualmin\Http\HttpClientInterface in the dependency injection container

This commit is contained in:
Tsvetelin Tsonev 2018-04-21 12:16:14 +02:00 committed by GitHub
parent e43be86156
commit bf453ce944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -11,7 +11,7 @@ use Nilemin\Virtualmin\Managers\DNS\DNSManager;
use Nilemin\Virtualmin\Managers\SSL\SSLManager; use Nilemin\Virtualmin\Managers\SSL\SSLManager;
use Nilemin\Virtualmin\Managers\Scripts\ScriptsManager; use Nilemin\Virtualmin\Managers\Scripts\ScriptsManager;
use Nilemin\Virtualmin\Managers\Cron\CronManager; use Nilemin\Virtualmin\Managers\Cron\CronManager;
use Nilemin\Virtualmin\Http\HttpClient; use Nilemin\Virtualmin\Http\HttpClientInterface;
use Nilet\Components\Configuration\Config; use Nilet\Components\Configuration\Config;
use Nilet\Components\Container\DependencyContainer; use Nilet\Components\Container\DependencyContainer;
@ -22,7 +22,7 @@ class Virtualmin {
/** /**
* Http client. * Http client.
* @var HttpClient * @var Nilemin\Virtualmin\Http\HttpClientInterface
*/ */
private $httpClient = null; private $httpClient = null;
@ -41,6 +41,7 @@ class Virtualmin {
$this->httpClient = new HttpClient($url, $port, $rootName, $rootPassword, "json"); $this->httpClient = new HttpClient($url, $port, $rootName, $rootPassword, "json");
$this->dc = new DependencyContainer(); $this->dc = new DependencyContainer();
$this->dc->instance(Config::class, $config); $this->dc->instance(Config::class, $config);
$this->dc->instance("Nilemin\\Virtualmin\\Http\\HttpClientInterface", function() { return $this->httpClient; });
} }
/** /**