Skip to content

Commit

Permalink
Прокси к контейнеру
Browse files Browse the repository at this point in the history
  • Loading branch information
ProklUng committed Jul 30, 2021
1 parent 1dd18a7 commit e97344f
Showing 1 changed file with 69 additions and 1 deletion.
70 changes: 69 additions & 1 deletion src/DI/AbstractServiceContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,74 @@ public function getContainer(): ?Container
return static::$container;
}

/**
* Фасад над методом get контейнера.
*
* @param string $serviceId ID сервиса.
*
* @return mixed
* @throws Exception
*/
public function get(string $serviceId)
{
if (static::$container === null) {
$this->load();
}

return static::$container->get($serviceId);
}

/**
* Фасад над методом has контейнера.
*
* @param string $serviceId ID сервиса.
*
* @return boolean
* @throws Exception
*/
public function has(string $serviceId) : bool
{
if (static::$container === null) {
$this->load();
}

return static::$container->has($serviceId);
}

/**
* Фасад над методом getParameter контейнера.
*
* @param string $param Параметр.
*
* @return mixed
* @throws Exception
*/
public function getParameter(string $param)
{
if (static::$container === null) {
$this->load();
}

return static::$container->getParameter($param);
}

/**
* Фасад над методом hasParameter контейнера.
*
* @param string $param Параметр.
*
* @return mixed
* @throws Exception
*/
public function hasParameter(string $param)
{
if (static::$container === null) {
$this->load();
}

return static::$container->hasParameter($param);
}

/**
* Создать пустой экземпляр контейнера.
*
Expand All @@ -156,4 +224,4 @@ private function createContainer() : void
$adapter->importParameters(static::$container, $this->parameters);
$adapter->importServices(static::$container, $this->services);
}
}
}

0 comments on commit e97344f

Please sign in to comment.