Source of file GeneratorInstance.php
Size: 4,224 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Di/ServiceLocator/GeneratorInstance.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Di\ServiceLocator; /** * Container for methods and parameters used by by Di to create a particular instance */ class GeneratorInstance { /** * @var string|null */ protected $class; /** * @var string|null */ protected $alias; /** * @var mixed */ protected $constructor; /** * @var array */ protected $params; /** * @var array */ protected $methods = array(); /** * @var bool */ protected $shared = true; /** * @param string|null $class * @param string|null $alias * @param mixed $constructor * @param array $params */ public function __construct($class, $alias, $constructor, array $params) { $this->class = $class; $this->alias = $alias; $this->constructor = $constructor; $this->params = $params; } /** * Retrieves the best available name for this instance (instance alias first then class name) * * @return string|null */ public function getName() { return $this->alias ? $this->alias : $this->class; } /** * Class of the instance. Null if class is unclear (such as when the instance is produced by a callback) * * @return string|null */ public function getClass() { return $this->class; } /** * Alias for the instance (if any) * * @return string|null */ public function getAlias() { return $this->alias; } /** * Set class name * * In the case of an instance created via a callback, we need to set the * class name after creating the generator instance. * * @param string $class * @return GeneratorInstance */ public function setClass($class) { $this->class = $class; return $this; } /** * Set instance alias * * @param string $alias * @return GeneratorInstance */ public function setAlias($alias) { $this->alias = $alias; return $this; } /** * Get instantiator * * @return mixed constructor method name or callable responsible for generating instance */ public function getConstructor() { return $this->constructor; } /** * Parameters passed to the instantiator as an ordered list of parameters. Each parameter that refers to another * instance fetched recursively is a GeneratorInstance itself * * @return array */ public function getParams() { return $this->params; } /** * Set methods * * @param array $methods * @return GeneratorInstance */ public function setMethods(array $methods) { $this->methods = $methods; return $this; } /** * Add a method called on the instance * * @param $method * @return GeneratorInstance */ public function addMethod($method) { $this->methods[] = $method; return $this; } /** * Retrieves a list of methods that are called on the instance in their call order. Each returned element has form * array('method' => 'methodName', 'params' => array( ... ordered list of call parameters ... ), where every call * parameter that is a recursively fetched instance is a GeneratorInstance itself * * @return array */ public function getMethods() { return $this->methods; } /** * @param bool $shared */ public function setShared($shared) { $this->shared = (bool) $shared; } /** * Retrieves whether the instance is shared or not * * @return bool */ public function isShared() { return $this->shared; } } |