mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-23 07:33:57 -06:00
Make it easier to switch between v1/v2 layout.
This commit is contained in:
parent
21da959203
commit
27815d0311
@ -133,7 +133,7 @@ class IndexController extends Controller
|
||||
// get all inactive budgets, and simply list them:
|
||||
$inactive = $this->repository->getInactiveBudgets();
|
||||
|
||||
return view(
|
||||
return prefixView(
|
||||
'budgets.index', compact(
|
||||
'availableBudgets', 'budgeted', 'spent', 'prevLoop', 'nextLoop', 'budgets', 'currencies', 'enableAddButton', 'periodTitle',
|
||||
'defaultCurrency', 'activeDaysPassed', 'activeDaysLeft', 'inactive', 'budgets', 'start', 'end', 'sums'
|
||||
|
@ -148,6 +148,6 @@ class HomeController extends Controller
|
||||
$user = auth()->user();
|
||||
event(new RequestedVersionCheckStatus($user));
|
||||
|
||||
return view('index', compact('count', 'subTitle', 'transactions', 'billCount', 'start', 'end', 'today'));
|
||||
return prefixView('index', compact('count', 'subTitle', 'transactions', 'billCount', 'start', 'end', 'today'));
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Create The Application
|
||||
@ -56,6 +57,7 @@ if (!function_exists('str_is_equal')) {
|
||||
/**
|
||||
* @param string $left
|
||||
* @param string $right
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function str_is_equal(string $left, string $right): bool
|
||||
@ -64,6 +66,41 @@ if (!function_exists('str_is_equal')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('prefixView')) {
|
||||
/**
|
||||
* Get the evaluated view contents for the given view.
|
||||
*
|
||||
* @param string|null $view
|
||||
* @param \Illuminate\Contracts\Support\Arrayable|array $data
|
||||
* @param array $mergeData
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
function prefixView($view = null, $data = [], $mergeData = [])
|
||||
{
|
||||
$factory = app(ViewFactory::class);
|
||||
|
||||
if (func_num_args() === 0) {
|
||||
return $factory;
|
||||
}
|
||||
$prefixView = $view;
|
||||
if (
|
||||
true === env('APP_DEBUG', false)
|
||||
&& null !== $view
|
||||
&& is_string($view)) {
|
||||
// do something with view:
|
||||
$layout = env('FIREFLY_III_LAYOUT', 'v1');
|
||||
$prefixView = sprintf('%s/%s', $layout, $view);
|
||||
if(false ===$factory->exists($view)) {
|
||||
// fall back to v1.
|
||||
$prefixView = sprintf('%s/%s', 'v1', $view);
|
||||
}
|
||||
}
|
||||
|
||||
return $factory->make($prefixView, $data, $mergeData);
|
||||
}
|
||||
}
|
||||
|
||||
$app = new Illuminate\Foundation\Application(
|
||||
realpath(__DIR__ . '/../')
|
||||
);
|
||||
|
@ -39,7 +39,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'view' => 'partials/layout/breadcrumbs',
|
||||
'view' => sprintf('%s/partials/layout/breadcrumbs', env('FIREFLY_III_LAYOUT', 'v1')),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -21,13 +21,6 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// simple hack to force v2. Used for demo until next release.
|
||||
$layout = env('FIREFLY_III_LAYOUT', 'v1');
|
||||
if (isset($_GET['layout']) && 'v2' === $_GET['layout'] && 'demo@firefly' === env('DEMO_USERNAME')) {
|
||||
$layout = 'v2';
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -41,7 +34,7 @@ return [
|
||||
*/
|
||||
|
||||
'paths' => [
|
||||
realpath(base_path(sprintf('resources/views/%s', $layout))),
|
||||
realpath(base_path('resources/views')),
|
||||
],
|
||||
|
||||
/*
|
||||
@ -55,6 +48,6 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'compiled' => realpath(storage_path(sprintf('framework/views/%s', $layout))),
|
||||
'compiled' => realpath(storage_path('framework/views')),
|
||||
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user