77use Command \ErrorCommand ;
88use DI \Container ;
99use DI \ContainerBuilder ;
10- use Plugin \Package ;
10+ use Plugin \Loader ;
1111
1212abstract class BaseApplication
1313{
1414 public function __construct ($ noFsIO )
1515 {
1616 $ this ->noFsIO = $ noFsIO ;
1717 $ this ->createContainer ();
18- $ this ->pluginsPackage = $ this ->container ->get (Package ::class);
18+ $ this ->pluginsLoader = $ this ->container ->get (Loader ::class);
1919 $ this ->loadPlugins ();
2020 }
2121 public function handle ($ request , $ response , $ data )
@@ -68,21 +68,7 @@ protected function getRouter()
6868 }
6969 protected function loadPlugins ()
7070 {
71- $ plugins = $ this ->pluginsPackage ->getPluginsList ();
72- foreach ($ plugins as $ pluginName ) {
73- $ parts = explode ("/ " , $ pluginName );
74- $ className = implode ("\\" , array_map (function ($ part ) {
75- return ucfirst ($ part );
76- }, $ parts ));
77- $ className .= "\\Plugin " ;
78- try {
79- /** @var \Plugin\PluginInterface */
80- $ plugin = $ this ->container ->get ($ className );
81- $ plugin ->init ();
82- } catch (\Exception $ e ) {
83- printf ("Plugin Error: %s \n" , $ e ->getMessage ());
84- }
85- }
71+ return $ this ->pluginsLoader ->load ();
8672 }
8773 abstract protected function getCommandName ($ request );
8874 protected function createContainer ()
@@ -94,8 +80,8 @@ protected function createContainer()
9480 }
9581
9682 protected $ router ;
97- /** @var Package */
98- protected $ pluginsPackage ;
83+ /** @var Loader */
84+ protected $ pluginsLoader ;
9985 static protected $ projectsPool = [];
10086 static protected $ currentProject = null ;
10187 /** @var Container */
0 commit comments