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\Builder
;
13 * Object containing definitions for a single class
20 protected $defaultMethodBuilder = 'Zend\Di\Definition\Builder\InjectionMethod';
25 protected $name = null;
28 * @var string|\Callable|array
30 protected $instantiator = '__construct';
33 * @var InjectionMethod[]
35 protected $injectionMethods = array();
40 protected $superTypes = array();
48 public function setName($name)
60 public function getName()
66 * @param string|\Callable|array $instantiator
69 public function setInstantiator($instantiator)
71 $this->instantiator
= $instantiator;
77 * @return array|\Callable|string
79 public function getInstantiator()
81 return $this->instantiator
;
85 * @param string $superType
88 public function addSuperType($superType)
90 $this->superTypes
[] = $superType;
100 public function getSuperTypes()
102 return $this->superTypes
;
106 * Add injection method
108 * @param InjectionMethod $injectionMethod
111 public function addInjectionMethod(InjectionMethod
$injectionMethod)
113 $this->injectionMethods
[] = $injectionMethod;
119 * Create and register an injection method
121 * Optionally takes the method name.
123 * This method may be used in lieu of addInjectionMethod() in
124 * order to provide a more fluent interface for building classes with
127 * @param null|string $name
128 * @return InjectionMethod
130 public function createInjectionMethod($name = null)
132 $builder = $this->defaultMethodBuilder
;
133 /* @var $method InjectionMethod */
134 $method = new $builder();
135 if (null !== $name) {
136 $method->setName($name);
138 $this->addInjectionMethod($method);
144 * Override which class will be used by {@link createInjectionMethod()}
146 * @param string $class
149 public function setMethodBuilder($class)
151 $this->defaultMethodBuilder
= $class;
157 * Determine what class will be used by {@link createInjectionMethod()}
159 * Mainly to provide the ability to temporarily override the class used.
163 public function getMethodBuilder()
165 return $this->defaultMethodBuilder
;
169 * @return InjectionMethod[]
171 public function getInjectionMethods()
173 return $this->injectionMethods
;