25
25
use Symfony \Component \Filesystem \Filesystem ;
26
26
use Symfony \Component \Process \ExecutableFinder ;
27
27
28
- class AdapterContainer extends \Pimple
28
+ class AdapterContainer implements \ArrayAccess
29
29
{
30
+
31
+ private $ items = array ();
32
+
30
33
/**
31
34
* Builds the adapter container
32
35
*
@@ -39,110 +42,180 @@ public static function load()
39
42
$ container ['zip.inflator ' ] = null ;
40
43
$ container ['zip.deflator ' ] = null ;
41
44
42
- $ container ['resource-manager ' ] = $ container -> share ( function ($ container ) {
45
+ $ container ['resource-manager ' ] = function ($ container ) {
43
46
return new ResourceManager (
44
47
$ container ['request-mapper ' ],
45
48
$ container ['resource-teleporter ' ],
46
49
$ container ['filesystem ' ]
47
50
);
48
- }) ;
51
+ };
49
52
50
- $ container ['executable-finder ' ] = $ container -> share ( function ($ container ) {
53
+ $ container ['executable-finder ' ] = function ($ container ) {
51
54
return new ExecutableFinder ();
52
- }) ;
55
+ };
53
56
54
- $ container ['request-mapper ' ] = $ container -> share ( function ($ container ) {
57
+ $ container ['request-mapper ' ] = function ($ container ) {
55
58
return new RequestMapper ($ container ['target-locator ' ]);
56
- }) ;
59
+ };
57
60
58
- $ container ['target-locator ' ] = $ container -> share ( function () {
61
+ $ container ['target-locator ' ] = function () {
59
62
return new TargetLocator ();
60
- }) ;
63
+ };
61
64
62
- $ container ['teleporter-container ' ] = $ container -> share ( function ($ container ) {
65
+ $ container ['teleporter-container ' ] = function ($ container ) {
63
66
return TeleporterContainer::load ();
64
- }) ;
67
+ };
65
68
66
- $ container ['resource-teleporter ' ] = $ container -> share ( function ($ container ) {
69
+ $ container ['resource-teleporter ' ] = function ($ container ) {
67
70
return new ResourceTeleporter ($ container ['teleporter-container ' ]);
68
- }) ;
71
+ };
69
72
70
- $ container ['filesystem ' ] = $ container -> share ( function () {
73
+ $ container ['filesystem ' ] = function () {
71
74
return new Filesystem ();
72
- }) ;
75
+ };
73
76
74
- $ container ['Alchemy \\Zippy \\Adapter \\ZipAdapter ' ] = $ container -> share ( function ($ container ) {
77
+ $ container ['Alchemy \\Zippy \\Adapter \\ZipAdapter ' ] = function ($ container ) {
75
78
return ZipAdapter::newInstance (
76
79
$ container ['executable-finder ' ],
77
80
$ container ['resource-manager ' ],
78
81
$ container ['zip.inflator ' ],
79
82
$ container ['zip.deflator ' ]
80
83
);
81
- }) ;
84
+ };
82
85
83
86
$ container ['gnu-tar.inflator ' ] = null ;
84
87
$ container ['gnu-tar.deflator ' ] = null ;
85
88
86
- $ container ['Alchemy \\Zippy \\Adapter \\GNUTar \\TarGNUTarAdapter ' ] = $ container -> share ( function ($ container ) {
89
+ $ container ['Alchemy \\Zippy \\Adapter \\GNUTar \\TarGNUTarAdapter ' ] = function ($ container ) {
87
90
return TarGNUTarAdapter::newInstance (
88
91
$ container ['executable-finder ' ],
89
92
$ container ['resource-manager ' ],
90
93
$ container ['gnu-tar.inflator ' ],
91
94
$ container ['gnu-tar.deflator ' ]
92
95
);
93
- }) ;
96
+ };
94
97
95
- $ container ['Alchemy \\Zippy \\Adapter \\GNUTar \\TarGzGNUTarAdapter ' ] = $ container -> share ( function ($ container ) {
98
+ $ container ['Alchemy \\Zippy \\Adapter \\GNUTar \\TarGzGNUTarAdapter ' ] = function ($ container ) {
96
99
return TarGzGNUTarAdapter::newInstance (
97
100
$ container ['executable-finder ' ],
98
101
$ container ['resource-manager ' ],
99
102
$ container ['gnu-tar.inflator ' ],
100
103
$ container ['gnu-tar.deflator ' ]
101
104
);
102
- }) ;
105
+ };
103
106
104
- $ container ['Alchemy \\Zippy \\Adapter \\GNUTar \\TarBz2GNUTarAdapter ' ] = $ container -> share ( function ($ container ) {
107
+ $ container ['Alchemy \\Zippy \\Adapter \\GNUTar \\TarBz2GNUTarAdapter ' ] = function ($ container ) {
105
108
return TarBz2GNUTarAdapter::newInstance (
106
109
$ container ['executable-finder ' ],
107
110
$ container ['resource-manager ' ],
108
111
$ container ['gnu-tar.inflator ' ],
109
112
$ container ['gnu-tar.deflator ' ]
110
113
);
111
- }) ;
114
+ };
112
115
113
116
$ container ['bsd-tar.inflator ' ] = null ;
114
117
$ container ['bsd-tar.deflator ' ] = null ;
115
118
116
- $ container ['Alchemy \\Zippy \\Adapter \\BSDTar \\TarBSDTarAdapter ' ] = $ container -> share ( function ($ container ) {
119
+ $ container ['Alchemy \\Zippy \\Adapter \\BSDTar \\TarBSDTarAdapter ' ] = function ($ container ) {
117
120
return TarBSDTarAdapter::newInstance (
118
121
$ container ['executable-finder ' ],
119
122
$ container ['resource-manager ' ],
120
123
$ container ['bsd-tar.inflator ' ],
121
124
$ container ['bsd-tar.deflator ' ]
122
125
);
123
- }) ;
126
+ };
124
127
125
- $ container ['Alchemy \\Zippy \\Adapter \\BSDTar \\TarGzBSDTarAdapter ' ] = $ container -> share ( function ($ container ) {
128
+ $ container ['Alchemy \\Zippy \\Adapter \\BSDTar \\TarGzBSDTarAdapter ' ] = function ($ container ) {
126
129
return TarGzBSDTarAdapter::newInstance (
127
130
$ container ['executable-finder ' ],
128
131
$ container ['resource-manager ' ],
129
132
$ container ['bsd-tar.inflator ' ],
130
133
$ container ['bsd-tar.deflator ' ]
131
134
);
132
- }) ;
135
+ };
133
136
134
- $ container ['Alchemy \\Zippy \\Adapter \\BSDTar \\TarBz2BSDTarAdapter ' ] = $ container -> share ( function ($ container ) {
137
+ $ container ['Alchemy \\Zippy \\Adapter \\BSDTar \\TarBz2BSDTarAdapter ' ] = function ($ container ) {
135
138
return TarBz2BSDTarAdapter::newInstance (
136
139
$ container ['executable-finder ' ],
137
140
$ container ['resource-manager ' ],
138
141
$ container ['bsd-tar.inflator ' ],
139
142
$ container ['bsd-tar.deflator ' ]);
140
- }) ;
143
+ };
141
144
142
- $ container ['Alchemy \\Zippy \\Adapter \\ZipExtensionAdapter ' ] = $ container -> share ( function () {
145
+ $ container ['Alchemy \\Zippy \\Adapter \\ZipExtensionAdapter ' ] = function () {
143
146
return ZipExtensionAdapter::newInstance ();
144
- }) ;
147
+ };
145
148
146
149
return $ container ;
147
150
}
151
+
152
+ /**
153
+ * (PHP 5 >= 5.0.0)<br/>
154
+ * Whether a offset exists
155
+ * @link http://php.net/manual/en/arrayaccess.offsetexists.php
156
+ * @param mixed $offset <p>
157
+ * An offset to check for.
158
+ * </p>
159
+ * @return boolean true on success or false on failure.
160
+ * </p>
161
+ * <p>
162
+ * The return value will be casted to boolean if non-boolean was returned.
163
+ */
164
+ public function offsetExists ($ offset )
165
+ {
166
+ return isset ($ this ->items [$ offset ]);
167
+ }
168
+
169
+ /**
170
+ * (PHP 5 >= 5.0.0)<br/>
171
+ * Offset to retrieve
172
+ * @link http://php.net/manual/en/arrayaccess.offsetget.php
173
+ * @param mixed $offset <p>
174
+ * The offset to retrieve.
175
+ * </p>
176
+ * @return mixed Can return all value types.
177
+ */
178
+ public function offsetGet ($ offset )
179
+ {
180
+ if (array_key_exists ($ offset , $ this ->items ) && is_callable ($ this ->items [$ offset ])) {
181
+ $ this ->items [$ offset ] = call_user_func ($ this ->items [$ offset ], $ this );
182
+ }
183
+
184
+ if (array_key_exists ($ offset , $ this ->items )) {
185
+ return $ this ->items [$ offset ];
186
+ }
187
+
188
+ throw new \InvalidArgumentException ();
189
+ }
190
+
191
+ /**
192
+ * (PHP 5 >= 5.0.0)<br/>
193
+ * Offset to set
194
+ * @link http://php.net/manual/en/arrayaccess.offsetset.php
195
+ * @param mixed $offset <p>
196
+ * The offset to assign the value to.
197
+ * </p>
198
+ * @param mixed $value <p>
199
+ * The value to set.
200
+ * </p>
201
+ * @return void
202
+ */
203
+ public function offsetSet ($ offset , $ value )
204
+ {
205
+ $ this ->items [$ offset ] = $ value ;
206
+ }
207
+
208
+ /**
209
+ * (PHP 5 >= 5.0.0)<br/>
210
+ * Offset to unset
211
+ * @link http://php.net/manual/en/arrayaccess.offsetunset.php
212
+ * @param mixed $offset <p>
213
+ * The offset to unset.
214
+ * </p>
215
+ * @return void
216
+ */
217
+ public function offsetUnset ($ offset )
218
+ {
219
+ unset($ this ->items [$ offset ]);
220
+ }
148
221
}
0 commit comments