4
* This file is part of the Nette Framework (http://nette.org)
6
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
8
* For the full copyright and license information, please view
9
* the file license.txt that was distributed with this source code.
18
* Definition used by ContainerBuilder.
22
class ServiceDefinition extends Nette\Object
24
/** @var string class or interface name */
30
/** @var Statement[] */
31
public $setup = array();
34
public $parameters = array();
37
public $tags = array();
40
public $autowired = TRUE;
43
public $shared = TRUE;
46
public $inject = FALSE;
48
/** @var string interface name */
52
public function setClass($class, array $args = array())
54
$this->class = $class;
56
$this->setFactory($class, $args);
62
public function setFactory($factory, array $args = array())
64
$this->factory = new Statement($factory, $args);
69
public function setArguments(array $args = array())
72
$this->factory->arguments = $args;
74
$this->setClass($this->class, $args);
80
public function addSetup($target, array $args = array())
82
$this->setup[] = new Statement($target, $args);
87
public function setParameters(array $params)
89
$this->shared = $this->autowired = FALSE;
90
$this->parameters = $params;
95
public function addTag($tag, $attrs = TRUE)
97
$this->tags[$tag] = $attrs;
102
public function setAutowired($on)
104
$this->autowired = $on;
109
public function setShared($on)
111
$this->shared = (bool) $on;
112
$this->autowired = $this->shared ? $this->autowired : FALSE;
117
public function setInject($on)
119
$this->inject = (bool) $on;
124
public function setImplement($implement)
126
$this->implement = $implement;
127
$this->shared = TRUE;