1212use CMW \Utils \Utils ;
1313use JetBrains \PhpStorm \ArrayShape ;
1414use JetBrains \PhpStorm \ExpectedValues ;
15+ use function extract ;
16+ use function in_array ;
1517use function is_file ;
18+ use function is_null ;
19+ use function ob_get_clean ;
20+ use function ob_start ;
21+ use function print_r ;
1622
1723class View
1824{
@@ -25,6 +31,7 @@ class View
2531 private bool $ needAdminControl ;
2632 private bool $ isAdminFile ;
2733 private string $ themeName ;
34+ private bool $ overrideBackendMode ;
2835
2936 /**
3037 * @param string|null $package
@@ -40,13 +47,14 @@ public function __construct(?string $package = null, ?string $viewFile = null, ?
4047 $ this ->needAdminControl = false ;
4148 $ this ->isAdminFile = $ isAdminFile ;
4249 $ this ->themeName = ThemeManager::getInstance ()->getCurrentTheme ()->name ();
50+ $ this ->overrideBackendMode = false ;
4351 }
4452
4553 /**
4654 * @param string $package
4755 * @param string $viewFile
4856 * @return void
49- * @throws \CMW\Manager\Router\ RouterException
57+ * @throws RouterException
5058 */
5159 public static function basicPublicView (string $ package , string $ viewFile ): void
5260 {
@@ -57,7 +65,7 @@ public static function basicPublicView(string $package, string $viewFile): void
5765 /**
5866 * @param string $package
5967 * @param string $viewFile
60- * @return \CMW\Manager\Views\ View
68+ * @return View
6169 */
6270 public static function createPublicView (string $ package , string $ viewFile ): View
6371 {
@@ -67,7 +75,7 @@ public static function createPublicView(string $package, string $viewFile): View
6775 /**
6876 * @param string $package
6977 * @param string $viewFile
70- * @return \CMW\Manager\Views\ View
78+ * @return View
7179 */
7280 public static function createAdminView (string $ package , string $ viewFile ): View
7381 {
@@ -264,6 +272,17 @@ public function setCustomTemplate(string $path): self
264272 return $ this ;
265273 }
266274
275+ /**
276+ * @param bool $overrideBackendMode
277+ * @return View
278+ * If true, the view will be displayed even if the backend mode is enabled
279+ */
280+ public function setOverrideBackendMode (bool $ overrideBackendMode ): self
281+ {
282+ $ this ->overrideBackendMode = $ overrideBackendMode ;
283+ return $ this ;
284+ }
285+
267286 /**
268287 * @return string
269288 */
@@ -438,6 +457,10 @@ private function backendView(): void
438457 {
439458 $ isBackendModeEnabled = EnvManager::getInstance ()->getValue ('ENABLE_BACKEND_MODE ' ) === 'true ' ;
440459
460+ if ($ this ->overrideBackendMode ) {
461+ return ;
462+ }
463+
441464 if ($ isBackendModeEnabled && !$ this ->needAdminControl ) {
442465 print_r (
443466 APIManager::createResponse (
0 commit comments