Skip to content

Commit 3c831cf

Browse files
author
rotimi
committed
In the catch all exception handler in ./public/index-dist.php, added code to replace all occurrences of the {{{APP_BASE_PATH}}} placeholder with the app base path in the error template file
1 parent 758ca75 commit 3c831cf

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

public/index-dist.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,25 @@ function sMVC_GetCurrentAppEnvironment(): string {
278278
} // try ... catch
279279
} // if(isset($container) && $container instanceof \Psr\Container\ContainerInterface)
280280

281-
echo str_replace(
282-
['{{{TITLE}}}', '{{{ERROR_HEADING}}}', '{{{ERROR_DETAILS}}}'],
283-
[$title, $title, $html],
284-
$error_template
285-
);
281+
$appBasePath = '';
282+
283+
if(
284+
isset($appSettings)
285+
&& \is_array($appSettings)
286+
&& \array_key_exists(AppSettingsKeys::APP_BASE_PATH, $appSettings)
287+
) {
288+
$appBasePath = ''.$appSettings[AppSettingsKeys::APP_BASE_PATH];
289+
290+
if(\str_ends_with($appBasePath, '/')) {
291+
292+
// remove trailing forward slash
293+
$appBasePath = \substr($appBasePath, 0, -1);
294+
}
295+
}
296+
297+
echo \str_replace(
298+
['{{{TITLE}}}', '{{{ERROR_HEADING}}}', '{{{ERROR_DETAILS}}}', '{{{APP_BASE_PATH}}}'],
299+
[$title, $title, $html, $appBasePath],
300+
$error_template
301+
);
286302
}

0 commit comments

Comments
 (0)