1: <?php
2:
3: 4: 5: 6:
7:
8: namespace Nette\DI;
9:
10: use Nette;
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: class ServiceDefinition extends Nette\Object
36: {
37:
38: private $class;
39:
40:
41: private $factory;
42:
43:
44: private $setup = array();
45:
46:
47: public $parameters = array();
48:
49:
50: private $tags = array();
51:
52:
53: private $autowired = TRUE;
54:
55:
56: public $inject = FALSE;
57:
58:
59: private $implement;
60:
61:
62: private $implementType;
63:
64:
65: public function setClass($class, array $args = array())
66: {
67: $this->class = $class;
68: if ($args) {
69: $this->setFactory($class, $args);
70: }
71: return $this;
72: }
73:
74:
75: public function setFactory($factory, array $args = array())
76: {
77: $this->factory = $factory instanceof Statement ? $factory : new Statement($factory, $args);
78: return $this;
79: }
80:
81:
82: public function setArguments(array $args = array())
83: {
84: if ($this->factory) {
85: $this->factory->arguments = $args;
86: } else {
87: $this->setClass($this->class, $args);
88: }
89: return $this;
90: }
91:
92:
93: public function addSetup($target, array $args = array())
94: {
95: $this->setup[] = new Statement($target, $args);
96: return $this;
97: }
98:
99:
100: public function addTag($tag, $attrs = TRUE)
101: {
102: $this->tags[$tag] = $attrs;
103: return $this;
104: }
105:
106:
107: public function getTag($tag)
108: {
109: return isset($this->tags[$tag]) ? $this->tags[$tag] : NULL;
110: }
111:
112:
113:
114: public function setShared($on)
115: {
116: trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
117: $this->autowired = $on ? $this->autowired : FALSE;
118: return $this;
119: }
120:
121:
122:
123: public function isShared()
124: {
125: trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
126: }
127:
128: }
129: