Add config.php at root; include configuration overhaul and then fixes to the installer #156
This commit is contained in:
46
app/Bootstrap/LoadConfiguration.php
Normal file
46
app/Bootstrap/LoadConfiguration.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bootstrap;
|
||||
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Config\Repository as RepositoryContract;
|
||||
|
||||
/**
|
||||
* Class LoadConfiguration
|
||||
* @package App\Bootstrap
|
||||
*
|
||||
* I'm overriding this to take advantage of the configuration caching
|
||||
* and not needing to read the files from disk every time.
|
||||
*
|
||||
* Hopefully it won't affect anything within core framework but this
|
||||
* should be ok. Will just have to be cognizant of any changes to the
|
||||
* LoadConfiguration parent class, or if the Kernel changes the boot
|
||||
* order -NS
|
||||
*/
|
||||
class LoadConfiguration extends \Illuminate\Foundation\Bootstrap\LoadConfiguration
|
||||
{
|
||||
/**
|
||||
* Load the configuration items from all of the files.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @param \Illuminate\Contracts\Config\Repository $repository
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function loadConfigurationFiles(Application $app, RepositoryContract $repository)
|
||||
{
|
||||
parent::loadConfigurationFiles($app, $repository);
|
||||
|
||||
/**
|
||||
* Read in the base config, only if it exists
|
||||
*/
|
||||
if (file_exists($app->basePath().'/config.php')) {
|
||||
$local_conf = include $app->basePath().'/config.php';
|
||||
foreach ($local_conf as $namespace => $override_config) {
|
||||
$config = $repository->get($namespace, []);
|
||||
$update_config = array_replace_recursive($config, $override_config);
|
||||
$repository->set($namespace, $update_config);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,6 @@ class InstalledCheck
|
||||
*
|
||||
* If the default key is set and we're not in any of the installer routes
|
||||
* show the message that we need to be installed
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Repositories\SettingRepository;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use App\Models\Flight;
|
||||
use App\Models\Pirep;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -18,29 +16,18 @@ class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
Relation::morphMap([
|
||||
'flights' => Flight::class,
|
||||
'pireps' => Pirep::class,
|
||||
]);
|
||||
|
||||
$this->app->bind('setting', SettingRepository::class);
|
||||
|
||||
//\VaCentral\VaCentral::setVaCentralUrl(config('phpvms.vacentral_api_url'));
|
||||
if(!empty(config('phpvms.vacentral_api_key'))) {
|
||||
\VaCentral\VaCentral::setApiKey(config('phpvms.vacentral_api_key'));
|
||||
}
|
||||
|
||||
# if there's a local.conf.php in the root, then merge that in
|
||||
if(file_exists(base_path('config.php'))) {
|
||||
/*if(file_exists(base_path('config.php'))) {
|
||||
$local_conf = include base_path('config.php');
|
||||
|
||||
foreach($local_conf as $namespace => $override_config) {
|
||||
$config = $this->app['config']->get($namespace, []);
|
||||
$this->app['config']->set(
|
||||
$namespace,
|
||||
array_merge($config, $override_config)
|
||||
);
|
||||
$update_config = array_merge_recursive($config, $override_config);
|
||||
$this->app['config']->set($namespace, $update_config);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use App\Listeners\NotificationEventListener;
|
||||
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
@@ -19,7 +20,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
];
|
||||
|
||||
protected $subscribe = [
|
||||
'App\Listeners\NotificationEventListener',
|
||||
NotificationEventListener::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
38
app/Services/AnalyticsService.php
Normal file
38
app/Services/AnalyticsService.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use DB;
|
||||
use PDO;
|
||||
|
||||
use Irazasyed\LaravelGAMP\Facades\GAMP;
|
||||
use App\Models\Enums\AnalyticsDimensions;
|
||||
|
||||
class AnalyticsService
|
||||
{
|
||||
/**
|
||||
* Send out some stats about the install
|
||||
*/
|
||||
public function sendInstall()
|
||||
{
|
||||
if(config('app.analytics') === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
# some analytics
|
||||
$gamp = GAMP::setClientId(uniqid('', true));
|
||||
$gamp->setDocumentPath('/install');
|
||||
|
||||
$gamp->setCustomDimension(PHP_VERSION, AnalyticsDimensions::PHP_VERSION);
|
||||
|
||||
# figure out database version
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$gamp->setCustomDimension(
|
||||
strtolower($pdo->getAttribute(PDO::ATTR_SERVER_VERSION)),
|
||||
AnalyticsDimensions::DATABASE_VERSION
|
||||
);
|
||||
|
||||
$gamp->sendPageview();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user