source: trunk/www.guidonia.net/wp/wp-content/plugins/tubepress/classes/net/sourceforge/phpcrafty/ComponentSpec.class.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 2.7 KB
Line 
1<?php
2
3/**
4 * Spefication container for the Dependency Injection factory to operate.
5 * @author Chris Corbyn
6 * @package Crafty
7 */
8class net_sourceforge_phpcrafty_ComponentSpec
9{
10
11 /**
12 * The class name.
13 * @var string
14 */
15 private $_className;
16
17 /**
18 * Arguments to be passed to the constructor.
19 * @var mixed[]
20 */
21 private $_constructorArgs = array();
22
23 /**
24 * Properties of the object.
25 * @var mixed[]
26 */
27 private $_properties = array();
28
29 /**
30 * True if the object should only be created once.
31 * @var boolean
32 */
33 private $_shared = false;
34
35 /**
36 * Creates a new ComponentSpec.
37 * @param string $className
38 * @param mixed[] $constructorArgs
39 * @param mixed[] $properties
40 * @param boolean $shared
41 */
42 public function __construct($className = null, $constructorArgs = array(),
43 $properties = array(), $shared = false)
44 {
45 $this->_className = $className;
46 $this->_constructorArgs = $constructorArgs;
47 $this->_properties = $properties;
48 $this->_shared = $shared;
49 }
50
51 /**
52 * Set the class name to $className.
53 * @param string $className
54 */
55 public function setClassName($className)
56 {
57 $this->_className = $className;
58 }
59
60 /**
61 * Get the class name.
62 * @return string
63 */
64 public function getClassName()
65 {
66 return $this->_className;
67 }
68
69 /**
70 * Set the arguments to be passed into the constructor.
71 * @param mixed[] Constructor arguments
72 */
73 public function setConstructorArgs($constructorArgs)
74 {
75 $this->_constructorArgs = $constructorArgs;
76 }
77
78 /**
79 * Get arguments to be passed to the constructor.
80 * @return mixed[]
81 */
82 public function getConstructorArgs()
83 {
84 return $this->_constructorArgs;
85 }
86
87 /**
88 * Set the property with name $key to value $value.
89 * A public setter named setPropName() is expected where $key is propName.
90 * @param string $key
91 * @param mixed $value
92 */
93 public function setProperty($key, $value)
94 {
95 $this->_properties[$key] = $value;
96 }
97
98 /**
99 * Get the value of the property named $key.
100 * @param string $key
101 * @return mixed
102 */
103 public function getProperty($key)
104 {
105 return $this->_properties[$key];
106 }
107
108 /**
109 * Get all properties as an associative array.
110 * @return mixed[]
111 */
112 public function getProperties()
113 {
114 return $this->_properties;
115 }
116
117 /**
118 * Make this component a shared instance, or turn sharing off.
119 * @param boolean $shared
120 */
121 public function setShared($shared)
122 {
123 $this->_shared = $shared;
124 }
125
126 /**
127 * Returns true if this component is a shared instance.
128 * @return boolean
129 */
130 public function isShared()
131 {
132 return $this->_shared;
133 }
134
135}
Note: See TracBrowser for help on using the repository browser.