@@ -59,7 +59,7 @@ public function __construct(array $options = [])
5959 'folder ' => 'blueprints ' ,
6060 'name ' => self ::ANY_PHP_OR_YML ,
6161 'key ' => 'relativepath ' ,
62- 'require ' => false ,
62+ 'require ' => true , // false
6363 'transform ' => fn ($ key ) => strtolower ($ key ),
6464 ],
6565 'classes ' => [
@@ -213,6 +213,7 @@ private function registry(string $type): array
213213 }
214214 }
215215 }
216+
216217 if (empty ($ key )) {
217218 continue ;
218219 } else {
@@ -246,12 +247,16 @@ private function registry(string $type): array
246247 is_array ($ route ) ? $ route : []
247248 );
248249 }
249- } elseif ($ options ['require ' ] && $ extension && strtolower ($ extension ) === 'php ' ) {
250- $ path = $ file ->getPathname ();
251- $ this ->registry [$ type ][$ key ] = require_once $ path ;
252250 } elseif ($ options ['folder ' ] === 'blueprints ' && $ extension && strtolower ($ extension ) === 'php ' ) {
253251 $ path = $ file ->getPathname ();
254- $ this ->registry [$ type ][$ key ] = require_once $ path ;
252+ $ this ->registry [$ type ][$ key ] = include $ path ; // require will link, include will read
253+ if (is_array ($ this ->registry [$ type ][$ key ])) {
254+ $ kk = explode ('/ ' , $ key );
255+ $ this ->registry [$ type ][$ key ]['name ' ] = array_pop ($ kk );
256+ }
257+ } elseif ($ options ['require ' ] && $ extension && strtolower ($ extension ) === 'php ' ) {
258+ $ path = $ file ->getPathname ();
259+ $ this ->registry [$ type ][$ key ] = include $ path ; // require will link, include will read
255260 } elseif ($ options ['require ' ] && $ extension && strtolower ($ extension ) === 'json ' ) {
256261 $ path = $ file ->getPathname ();
257262 $ this ->registry [$ type ][$ key ] = json_decode (file_get_contents ($ path ), true );
@@ -264,6 +269,10 @@ private function registry(string $type): array
264269 } else {
265270 $ this ->registry [$ type ][$ key ] = Spyc::YAMLLoadString ($ yaml );
266271 }
272+ if (is_array ($ this ->registry [$ type ][$ key ]) && $ options ['folder ' ] === 'blueprints ' ) {
273+ $ kk = explode ('/ ' , $ key );
274+ $ this ->registry [$ type ][$ key ]['name ' ] = array_pop ($ kk );
275+ }
267276 } else {
268277 $ this ->registry [$ type ][$ key ] = $ file ->getRealPath ();
269278 }
0 commit comments