blob: 6c7accd91d22ff988fc19fdda22e390cf4fef9ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
<?php
use Psr\Container\ContainerInterface;
/**
* This function returns the Dependency Injection container used.
*
* ```
* $container = app();
* ```
*
* You may pass an entry name, a class or interface name to resolve it from the container:
*
* ```
* $logger = app(LoggerInterface::class);
* ```
*
* @param string|null $entryId entry name or a class name
* @param array $parameters Optional parameters to use to build the entry.
* Use this to force specific parameters to specific values.
* Parameters not defined in this array will be resolved using the container.
*
* @return ContainerInterface|mixed either the DI container or the entry associated to the $entryId
*/
function app($entryId = null, $parameters = [])
{
$container = \Studip\DIContainer::getInstance();
if (is_null($entryId)) {
return $container;
}
return $container->make($entryId, $parameters);
}
|