1 | <?php |
||
21 | trait ConfigTrait |
||
22 | { |
||
23 | /** |
||
24 | * @var Config |
||
25 | */ |
||
26 | private $config; |
||
27 | |||
28 | /** |
||
29 | * Return registered service |
||
30 | * |
||
31 | * @param string $service Service name |
||
32 | * @return mixed |
||
33 | */ |
||
34 | abstract public function get($service); |
||
35 | |||
36 | /** |
||
37 | * @param string $name |
||
38 | * @param mixed $service |
||
39 | */ |
||
40 | abstract protected function setServicesService($name, $service); |
||
41 | |||
42 | /** |
||
43 | * Attach a listener to an event |
||
44 | * |
||
45 | * @param string|\Zend\EventManager\ListenerAggregateInterface $event |
||
46 | * @param string|callable|int $callback If string $event provided, expects PHP callback; |
||
47 | * @param int $priority Invocation priority |
||
48 | * @return \Zend\Stdlib\CallbackHandler|mixed CallbackHandler if attaching callable |
||
49 | * (to allow later unsubscribe); mixed if attaching aggregate |
||
50 | */ |
||
51 | abstract public function bind($event, $callback = null, $priority = 1); |
||
52 | |||
53 | /** |
||
54 | * Require service from services into application |
||
55 | * |
||
56 | * @param string $service Service name |
||
57 | * @throws Exception\DomainException Unable to get service |
||
58 | */ |
||
59 | abstract protected function requireService($service); |
||
60 | |||
61 | /** |
||
62 | * @param string|null $name |
||
63 | * @param mixed|null $default |
||
64 | * @return Config|mixed |
||
65 | */ |
||
66 | public function getConfig($name = null, $default = null) |
||
74 | |||
75 | /** |
||
76 | * @param array|Config|object $config |
||
77 | * @throws Exception\InvalidArgumentException Expected config as array|Config |
||
78 | * @throws Exception\DomainException Disallowed config modifications |
||
79 | */ |
||
80 | public function setConfig($config) |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | public function getCoreConfig($name = null, $default = null) |
||
109 | |||
110 | /** |
||
111 | * @param callable $callback |
||
112 | */ |
||
113 | public function onConfig(callable $callback) |
||
119 | } |
||
120 |