Cachet/app/Providers/LoadConfigServiceProvider.php
Joseph Cohen 41186b7271 CS fixes
2015-03-21 02:56:01 -06:00

54 lines
1.4 KiB
PHP

<?php
namespace CachetHQ\Cachet\Providers;
use CachetHQ\Cachet\Facades\Setting;
use Exception;
use Illuminate\Support\ServiceProvider;
class LoadConfigServiceProvider extends ServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
$appDomain = $appLocale = null;
try {
// Get app custom configuration.
$appDomain = Setting::get('app_domain');
$appLocale = Setting::get('app_locale');
} catch (Exception $e) {
// Don't throw any errors, we may not be setup yet.
}
// Set the Segment.com settings.
try {
$segmentRepository = $this->app->make('CachetHQ\Cachet\Segment\RepositoryInterface');
$this->app->config->set('segment.write_key', $segmentRepository->fetch());
} catch (Exception $e) {
// Don't throw any errors, we may not be able to fetch.
}
// Override default app values.
$this->app->config->set('app.url', $appDomain ?: $this->app->config->get('app.url'));
$this->app->config->set('app.locale', $appLocale ?: $this->app->config->get('app.locale'));
// Set custom lang.
$this->app->translator->setLocale($appLocale);
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
}
}