Improved the config system

This commit is contained in:
Graham Campbell
2016-01-29 22:49:06 +00:00
parent 51e850ddc2
commit 1b24cdb1c5
35 changed files with 188 additions and 232 deletions
@@ -11,11 +11,11 @@
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\Subscriber;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\View;
use Jenssegers\Date\Date;
@@ -43,7 +43,7 @@ class DashboardController extends Controller
public function __construct()
{
$this->startDate = new Date();
$this->dateTimeZone = Setting::get('app_timezone');
$this->dateTimeZone = Config::get('cachet.timezone');
}
/**
@@ -11,11 +11,11 @@
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\User;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
@@ -102,7 +102,7 @@ class SettingsController extends Controller
return View::make('dashboard.settings.app-setup')
->withPageTitle(trans('dashboard.settings.app-setup.app-setup').' - '.trans('dashboard.dashboard'))
->withSubMenu($this->subMenu)
->withRawAppAbout(Setting::get('app_about'));
->withRawAppAbout(Config::get('setting.app_about'));
}
/**
@@ -197,8 +197,10 @@ class SettingsController extends Controller
{
$redirectUrl = Session::get('redirect_to', route('dashboard.settings.setup'));
$setting = app('setting');
if (Binput::get('remove_banner') === '1') {
Setting::set('app_banner', null);
$setting->set('app_banner', null);
}
if (Binput::hasFile('app_banner')) {
@@ -221,10 +223,10 @@ class SettingsController extends Controller
}
// Store the banner.
Setting::set('app_banner', base64_encode(file_get_contents($file->getRealPath())));
$setting->set('app_banner', base64_encode(file_get_contents($file->getRealPath())));
// Store the banner type.
Setting::set('app_banner_type', $file->getMimeType());
$setting->set('app_banner_type', $file->getMimeType());
}
try {
@@ -233,7 +235,7 @@ class SettingsController extends Controller
$settingValue = rtrim($settingValue, '/');
}
Setting::set($settingName, $settingValue);
$setting->set($settingName, $settingValue);
}
} catch (Exception $e) {
return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.edit.failure'));
+5 -5
View File
@@ -11,11 +11,11 @@
namespace CachetHQ\Cachet\Http\Controllers;
use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Incident;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Str;
use Roumen\Feed\Facades\Feed;
@@ -36,9 +36,9 @@ class FeedController extends Controller
public function __construct()
{
$this->feed = Feed::make();
$this->feed->title = Setting::get('app_name');
$this->feed->title = Config::get('setting.app_name');
$this->feed->description = trans('cachet.feed');
$this->feed->link = Str::canonicalize(Setting::get('app_domain'));
$this->feed->link = Str::canonicalize(Config::get('setting.app_domain'));
$this->feed->setDateFormat('datetime');
}
@@ -63,7 +63,7 @@ class FeedController extends Controller
*/
public function rssAction(ComponentGroup $group = null)
{
$this->feed->lang = Setting::get('app_locale');
$this->feed->lang = Config::get('setting.app_locale');
return $this->feedAction($group, true);
}
@@ -103,7 +103,7 @@ class FeedController extends Controller
{
$this->feed->add(
$incident->name,
Setting::get('app_name'),
Config::get('setting.app_name'),
Str::canonicalize(route('incident', ['id' => $incident->id])),
$isRss ? $incident->created_at->toRssString() : $incident->created_at->toAtomString(),
$isRss ? $incident->message : Markdown::convertToHtml($incident->message)
+3 -2
View File
@@ -11,7 +11,6 @@
namespace CachetHQ\Cachet\Http\Controllers;
use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\User;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Routing\Controller;
@@ -179,10 +178,12 @@ class SetupController extends Controller
Auth::login($user);
$setting = app('setting');
$settings = array_pull($postData, 'settings');
foreach ($settings as $settingName => $settingValue) {
Setting::set($settingName, $settingValue);
$setting->set($settingName, $settingValue);
}
$envData = array_pull($postData, 'env');
@@ -11,12 +11,12 @@
namespace CachetHQ\Cachet\Http\Controllers;
use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\Incident;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\View;
use Jenssegers\Date\Date;
@@ -47,14 +47,14 @@ class StatusPageController extends Controller
}
}
$daysToShow = Setting::get('app_incident_days', 0) - 1;
$daysToShow = Config::get('setting.app_incident_days', 0) - 1;
if ($daysToShow < 0) {
$daysToShow = 0;
$incidentDays = [];
} else {
$incidentDays = range(0, $daysToShow);
}
$dateTimeZone = Setting::get('app_timezone');
$dateTimeZone = Config::get('cachet.timezone');
$incidentVisibility = Auth::check() ? 0 : 1;
+3 -3
View File
@@ -16,13 +16,13 @@ use CachetHQ\Cachet\Bus\Commands\Subscriber\SubscribeSubscriberCommand;
use CachetHQ\Cachet\Bus\Commands\Subscriber\UnsubscribeSubscriberCommand;
use CachetHQ\Cachet\Bus\Commands\Subscriber\UnsubscribeSubscriptionCommand;
use CachetHQ\Cachet\Bus\Commands\Subscriber\VerifySubscriberCommand;
use CachetHQ\Cachet\Bus\Exceptions\Subscriber\AlreadySubscribedException;
use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Exceptions\AlreadySubscribedException;
use CachetHQ\Cachet\Models\Subscriber;
use CachetHQ\Cachet\Models\Subscription;
use GrahamCampbell\Binput\Facades\Binput;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@@ -43,7 +43,7 @@ class SubscribeController extends Controller
public function showSubscribe()
{
return View::make('subscribe')
->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')));
->withAboutApp(Markdown::convertToHtml(Config::get('setting.app_about')));
}
/**