Files
firefly-iii/app/Http/Controllers/Controller.php

93 lines
3.4 KiB
PHP
Raw Normal View History

<?php
/**
* Controller.php
2017-10-21 08:40:00 +02:00
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
2017-10-21 08:40:00 +02:00
* This file is part of Firefly III.
*
2017-10-21 08:40:00 +02:00
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2017-12-17 14:41:58 +01:00
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
2015-02-06 04:39:52 +01:00
namespace FireflyIII\Http\Controllers;
use FireflyIII\Support\Http\Controllers\RequestInformation;
use FireflyIII\Support\Http\Controllers\UserNavigation;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
2015-06-13 10:02:36 +02:00
use Illuminate\Foundation\Bus\DispatchesJobs;
2015-02-06 04:39:52 +01:00
use Illuminate\Foundation\Validation\ValidatesRequests;
2015-02-11 07:35:10 +01:00
use Illuminate\Routing\Controller as BaseController;
use Route;
2015-02-06 04:39:52 +01:00
2015-02-11 07:35:10 +01:00
/**
2017-11-15 12:25:49 +01:00
* Class Controller.
2018-07-17 22:21:03 +02:00
*
* @SuppressWarnings(PHPMD.NumberOfChildren)
2015-02-11 07:35:10 +01:00
*/
class Controller extends BaseController
2015-02-11 07:35:10 +01:00
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, UserNavigation, RequestInformation;
2015-05-14 13:41:21 +02:00
2018-07-22 08:10:16 +02:00
/** @var string Format for date and time. */
2016-03-01 21:31:25 +01:00
protected $dateTimeFormat;
2018-07-22 08:10:16 +02:00
/** @var string Format for "23 Feb, 2016". */
2016-01-09 07:48:45 +01:00
protected $monthAndDayFormat;
2018-07-22 08:10:16 +02:00
/** @var string Format for "March 2018" */
2016-01-24 15:58:16 +01:00
protected $monthFormat;
2018-07-22 08:10:16 +02:00
/** @var string Redirect user */
protected $redirectUri = '/';
2016-01-09 07:48:45 +01:00
2015-04-28 15:26:30 +02:00
/**
* Controller constructor.
2015-04-28 15:26:30 +02:00
*/
public function __construct()
{
2017-07-22 10:50:30 +02:00
// for transaction lists:
app('view')->share('hideBudgets', false);
app('view')->share('hideCategories', false);
app('view')->share('hideBills', false);
app('view')->share('hideTags', false);
2017-07-22 10:50:30 +02:00
// is site a demo site?
2019-02-13 17:38:41 +01:00
$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
app('view')->share('IS_DEMO_SITE', $isDemoSite);
app('view')->share('DEMO_USERNAME', config('firefly.demo_username'));
app('view')->share('DEMO_PASSWORD', config('firefly.demo_password'));
app('view')->share('FF_VERSION', config('firefly.version'));
2016-10-29 07:44:46 +02:00
$this->middleware(
function ($request, $next) {
2017-07-22 10:50:30 +02:00
// translations for specific strings:
2016-10-29 07:44:46 +02:00
$this->monthFormat = (string)trans('config.month');
$this->monthAndDayFormat = (string)trans('config.month_and_day');
$this->dateTimeFormat = (string)trans('config.date_time');
// get shown-intro-preference:
if (auth()->check()) {
2018-07-17 22:21:03 +02:00
$language = $this->getLanguage();
$page = $this->getPageName();
$shownDemo = $this->hasSeenDemo();
app('view')->share('language', $language);
app('view')->share('shownDemo', $shownDemo);
app('view')->share('current_route_name', $page);
app('view')->share('original_route_name', Route::currentRouteName());
}
2016-10-29 07:44:46 +02:00
return $next($request);
}
);
2015-04-28 15:26:30 +02:00
}
2015-12-31 17:20:54 +01:00
2015-02-06 04:39:52 +01:00
}