Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

Commit e44a87c

Browse files
committed
ref: clean up the upstart class
1 parent a9b2fe2 commit e44a87c

File tree

1 file changed

+55
-14
lines changed

1 file changed

+55
-14
lines changed

Upstart.php

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace Modulus\Framework;
44

5+
use Modulus\Framework\Plugin\Load;
56
use App\Resolvers\AppServiceResolver;
67
use Modulus\Framework\Upstart\AppLogger;
8+
use Modulus\Framework\Upstart\Prototype;
79
use Modulus\Framework\Upstart\AppConnect;
810
use Modulus\Framework\Upstart\HandleCors;
911
use Modulus\Framework\Upstart\ErrorReport;
@@ -44,47 +46,86 @@ class Upstart
4446
*/
4547
public function boot(?bool $isConsole = false) : void
4648
{
49+
/**
50+
* Add cors to the request
51+
*/
4752
$this->addCors();
53+
54+
/**
55+
* Don't load framework components, if
56+
* the application has already started.
57+
*/
4858
if (Upstart::$isReady) return;
4959

60+
/**
61+
* Load application components
62+
*/
63+
$this->startCore($isConsole);
64+
$this->startApp($isConsole);
65+
$this->startRouter($isConsole);
66+
67+
/**
68+
* Mark "application" as ready to indicate, that
69+
* it has started.
70+
*/
71+
Upstart::$isReady = true;
72+
}
73+
74+
/**
75+
* Load the core components
76+
*
77+
* @param bool $isConsole
78+
* @return void
79+
*/
80+
private function startCore(bool $isConsole)
81+
{
5082
$this->bootEnv();
5183
$this->initialize();
5284
$this->logger();
5385
$this->errorHandling($isConsole);
5486
$this->bootRemember();
5587

88+
/**
89+
* Create class aliases
90+
*/
5691
$aliases = config('app.aliases');
5792

5893
foreach($aliases as $alias => $class) {
5994
class_alias($class, $alias);
6095
}
96+
}
6197

98+
/**
99+
* Boot the application
100+
*
101+
* @param bool $isConsole
102+
* @return void
103+
*/
104+
private function startApp(bool $isConsole)
105+
{
62106
(new AppServiceResolver)->start(Application::prototype($isConsole));
63107

64-
$this->autoload_plugins($isConsole);
108+
/**
109+
* Load framework plugins
110+
*/
111+
Load::plugins($isConsole);
65112

113+
/**
114+
* Extend the medusa templating language
115+
*/
66116
$this->directives();
67-
$this->handleSwish();
68-
$this->route($isConsole);
69-
70-
Upstart::$isReady = true;
71117
}
72118

73119
/**
74-
* autoload_plugins
120+
* Start the application router
75121
*
76122
* @param bool $isConsole
77123
* @return void
78124
*/
79-
public function autoload_plugins(bool $isConsole)
125+
private function startRouter(bool $isConsole)
80126
{
81-
$plugins = config('app.plugins');
82-
83-
if (env('DEV_AUTOLOAD_PLUGINS') == true) {
84-
foreach($plugins as $plugin => $class) {
85-
$class::boot((object)Application::prototype($isConsole));
86-
}
87-
}
127+
$this->handleSwish();
128+
$this->route($isConsole);
88129
}
89130

90131
/**

0 commit comments

Comments
 (0)