3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Di\Definition
;
12 use Zend\Di\Definition\Builder\InjectionMethod
;
15 * Class definitions based on a given array
17 class ArrayDefinition
implements DefinitionInterface
22 protected $dataArray = array();
25 * @param array $dataArray
27 public function __construct(array $dataArray)
29 foreach ($dataArray as $class => $value) {
31 $dataArray[$class] = array_change_key_case($dataArray[$class], CASE_LOWER
);
33 foreach ($dataArray as $class => $definition) {
34 if (isset($definition['methods']) && is_array($definition['methods'])) {
35 foreach ($definition['methods'] as $type => $requirement) {
36 if (!is_int($requirement)) {
37 $dataArray[$class]['methods'][$type] = InjectionMethod
::detectMethodRequirement($requirement);
42 $this->dataArray
= $dataArray;
48 public function getClasses()
50 return array_keys($this->dataArray
);
56 public function hasClass($class)
58 return array_key_exists($class, $this->dataArray
);
64 public function getClassSupertypes($class)
66 if (!isset($this->dataArray
[$class])) {
70 if (!isset($this->dataArray
[$class]['supertypes'])) {
74 return $this->dataArray
[$class]['supertypes'];
80 public function getInstantiator($class)
82 if (!isset($this->dataArray
[$class])) {
86 if (!isset($this->dataArray
[$class]['instantiator'])) {
90 return $this->dataArray
[$class]['instantiator'];
96 public function hasMethods($class)
98 if (!isset($this->dataArray
[$class])) {
102 if (!isset($this->dataArray
[$class]['methods'])) {
106 return (count($this->dataArray
[$class]['methods']) > 0);
112 public function hasMethod($class, $method)
114 if (!isset($this->dataArray
[$class])) {
118 if (!isset($this->dataArray
[$class]['methods'])) {
122 return array_key_exists($method, $this->dataArray
[$class]['methods']);
128 public function getMethods($class)
130 if (!isset($this->dataArray
[$class])) {
134 if (!isset($this->dataArray
[$class]['methods'])) {
138 return $this->dataArray
[$class]['methods'];
144 public function hasMethodParameters($class, $method)
146 return isset($this->dataArray
[$class]['parameters'][$method]);
152 public function getMethodParameters($class, $method)
154 if (!isset($this->dataArray
[$class])) {
158 if (!isset($this->dataArray
[$class]['parameters'])) {
162 if (!isset($this->dataArray
[$class]['parameters'][$method])) {
166 return $this->dataArray
[$class]['parameters'][$method];
172 public function toArray()
174 return $this->dataArray
;