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() {}
80
80
*/
81
81
protected bool $ debug = false ;
82
82
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
+
83
94
// endregion
84
95
85
96
/**
@@ -115,7 +126,12 @@ public static function init(): void
115
126
static ::ensureNotKernelNamespace ();
116
127
117
128
$ instance = static ::getInstance ();
118
- $ instance ->ensureNotInitialized ();
129
+
130
+ if ($ instance ->throwExceptionOnDoubleInitialization ) {
131
+ $ instance ->ensureNotInitialized ();
132
+ } elseif ($ instance ->initialized ) {
133
+ return ;
134
+ }
119
135
120
136
// Initialize the services
121
137
$ instance ->preInit ();
You can’t perform that action at this time.
0 commit comments