File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ class Container implements \ArrayAccess
2121 */
2222 protected $ objects = array ();
2323
24+ /**
25+ * Table of generated objects
26+ */
27+ protected $ calcs = array ();
28+
2429 /**
2530 * Table of all closures that should always return fresh objects.
2631 */
@@ -57,6 +62,7 @@ public function set($id, $value)
5762 throw new Exception ("Cannot override locked key {$ id }" );
5863 }
5964 $ this ->definitions [$ id ] = $ value ;
65+ $ this ->calcs [$ id ] = false ;
6066 // unset on override
6167 unset($ this ->objects [$ id ]);
6268 }
@@ -83,11 +89,12 @@ public function get($id)
8389 return $ this ->definitions [$ id ]();
8490 }
8591
86- if (isset ( $ this ->objects [$ id ]) ) {
92+ if ($ this ->calcs [$ id ]) {
8793 return $ this ->objects [$ id ];
8894 }
8995 $ obj = $ this ->definitions [$ id ]();
9096 $ this ->objects [$ id ] = $ obj ;
97+ $ this ->calcs [$ id ] = true ;
9198
9299 return $ obj ;
93100 }
You can’t perform that action at this time.
0 commit comments