1 | <?php |
||
17 | abstract class Component |
||
18 | { |
||
19 | /** |
||
20 | * Global/static mainly used to resolve singletons outside of the runtime scope. |
||
21 | * Must be used as fallback only, or not used at all. All spiral components can |
||
22 | * behave well without it. |
||
23 | * |
||
24 | * @var ContainerInterface |
||
25 | */ |
||
26 | private static $staticContainer = null; |
||
27 | |||
28 | /** |
||
29 | * Get instance of container associated with given object, uses global container as fallback |
||
30 | * if not. Method generally used by traits. |
||
31 | * |
||
32 | * @return ContainerInterface|null |
||
33 | */ |
||
34 | 17 | protected function iocContainer() |
|
55 | |||
56 | /** |
||
57 | * Get/set instance of global/static container, due this method must be used as few times as |
||
58 | * possible both getter and setter methods joined into one. Please use this method only as |
||
59 | * fallback. |
||
60 | * |
||
61 | * @internal Do not use for business logic. |
||
62 | * |
||
63 | * @param ContainerInterface $container Can be set to null. |
||
64 | * |
||
65 | * @return ContainerInterface|null |
||
66 | */ |
||
67 | 17 | final protected static function staticContainer(ContainerInterface $container = null) |
|
80 | } |
||
81 |