This repository has been archived by the owner on Feb 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
/
Config.php
97 lines (77 loc) · 2.8 KB
/
Config.php
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ServiceManager
*/
namespace Zend\ServiceManager;
class Config implements ConfigInterface
{
protected $config = array();
public function __construct($config = array())
{
$this->config = $config;
}
public function getAllowOverride()
{
return (isset($this->config['allow_override'])) ? $this->config['allow_override'] : null;
}
public function getFactories()
{
return (isset($this->config['factories'])) ? $this->config['factories'] : array();
}
public function getAbstractFactories()
{
return (isset($this->config['abstract_factories'])) ? $this->config['abstract_factories'] : array();
}
public function getInvokables()
{
return (isset($this->config['invokables'])) ? $this->config['invokables'] : array();
}
public function getServices()
{
return (isset($this->config['services'])) ? $this->config['services'] : array();
}
public function getAliases()
{
return (isset($this->config['aliases'])) ? $this->config['aliases'] : array();
}
public function getInitializers()
{
return (isset($this->config['initializers'])) ? $this->config['initializers'] : array();
}
public function getShared()
{
return (isset($this->config['shared'])) ? $this->config['shared'] : array();
}
public function configureServiceManager(ServiceManager $serviceManager)
{
if (($allowOverride = $this->getAllowOverride()) !== null) {
$serviceManager->setAllowOverride($allowOverride);
}
foreach ($this->getFactories() as $name => $factory) {
$serviceManager->setFactory($name, $factory);
}
foreach ($this->getAbstractFactories() as $factory) {
$serviceManager->addAbstractFactory($factory);
}
foreach ($this->getInvokables() as $name => $invokable) {
$serviceManager->setInvokableClass($name, $invokable);
}
foreach ($this->getServices() as $name => $service) {
$serviceManager->setService($name, $service);
}
foreach ($this->getAliases() as $alias => $nameOrAlias) {
$serviceManager->setAlias($alias, $nameOrAlias);
}
foreach ($this->getInitializers() as $initializer) {
$serviceManager->addInitializer($initializer);
}
foreach ($this->getShared() as $name => $isShared) {
$serviceManager->setShared($name, $isShared);
}
}
}