Make it easier to switch between v1/v2 layout.

This commit is contained in:
James Cole 2021-02-01 06:47:33 +01:00
parent f16b7c4286
commit b8340ddb59
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D

View File

@ -83,19 +83,22 @@ if (!function_exists('prefixView')) {
if (func_num_args() === 0) { if (func_num_args() === 0) {
return $factory; return $factory;
} }
// original view:
$prefixView = $view; $prefixView = $view;
if (
true === env('APP_DEBUG', false) // try to find the view file first:
&& null !== $view if(!$factory->exists($prefixView)) {
&& is_string($view)) { // prepend it with the view in the layout:
// do something with view:
$layout = env('FIREFLY_III_LAYOUT', 'v1'); $layout = env('FIREFLY_III_LAYOUT', 'v1');
$prefixView = sprintf('%s/%s', $layout, $view); $prefixView = sprintf('%s.%s', $layout, $view);
if(false ===$factory->exists($prefixView)) {
// fall back to v1. // try again:
$prefixView = sprintf('%s/%s', 'v1', $view); if(!$factory->exists($prefixView)) {
// if does not exist, force v1 and just continue.
$prefixView = sprintf('%s.%s', 'v1', $view);
} }
} }
return $factory->make($prefixView, $data, $mergeData); return $factory->make($prefixView, $data, $mergeData);
} }
} }