File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,17 @@ public function __construct() {}
8080 */
8181 protected bool $ debug = false ;
8282
83+ /**
84+ * Throw an exception if the kernel is initialized twice.
85+ * <br><b>Default:</b> {@link false}<br>
86+ *
87+ * If {@link false}, any subsequent call to {@link init()} will be
88+ * ignored.
89+ *
90+ * @var bool
91+ */
92+ protected bool $ throwExceptionOnDoubleInitialization = false ;
93+
8394 // endregion
8495
8596 /**
@@ -115,7 +126,12 @@ public static function init(): void
115126 static ::ensureNotKernelNamespace ();
116127
117128 $ instance = static ::getInstance ();
118- $ instance ->ensureNotInitialized ();
129+
130+ if ($ instance ->throwExceptionOnDoubleInitialization ) {
131+ $ instance ->ensureNotInitialized ();
132+ } elseif ($ instance ->initialized ) {
133+ return ;
134+ }
119135
120136 // Initialize the services
121137 $ instance ->preInit ();
You can’t perform that action at this time.
0 commit comments