File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Axel \Module ;
3+ class Library implements \Axel \Module {
4+ private $ libraryDir ;
5+ private $ axel ;
6+
7+ public function __construct (\Axel \Axel $ axel , $ libraryDir ) {
8+ $ this ->axel = $ axel ;
9+ $ this ->libraryDir = $ libraryDir ;
10+ }
11+
12+ public function locate ($ className ) {
13+ $ rootNs = explode ('\\' , rtrim ('\\' , $ className ))[0 ];
14+ if (file_exists ($ this ->libraryDir . DIRECTORY_SEPARATOR . $ rootNs . DIRECTORY_SEPARATOR . 'autoload.json ' )) {
15+ $ json = json_decode (file_get_contents ($ this ->libraryDir . DIRECTORY_SEPARATOR . $ rootNs . DIRECTORY_SEPARATOR . 'autoload.json ' ));
16+
17+ if (isset ($ json ->include )) foreach ($ json ->include as $ file ) require_once $ this ->libaryDir . DIRECTORY_SEPARATOR . $ rootNs . DIRECTORY_SEPARATOR . $ file ;
18+
19+ foreach ($ json ->modules as $ key => $ value ) $ this ->axel ->addModule (new $ key (...$ value ));
20+ }
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments