111 lines
2.7 KiB
PHP
111 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Classes;
|
|
|
|
use Laravel\Lumen\Application as BaseApplication;
|
|
|
|
class Application extends BaseApplication {
|
|
public function setLocale() {
|
|
$locale = $this->app['config']->get('app.locale', 'en_US').'.UTF-8';
|
|
setlocale(LC_ALL, $locale);
|
|
putenv('LANG='.$locale);
|
|
putenv('OS_LOCALE='.$locale);
|
|
putenv('LANGUAGE='.$locale);
|
|
}
|
|
|
|
public function configure($name) {
|
|
if(isset($this->loadedConfigurations[$name])) {
|
|
return;
|
|
}
|
|
|
|
$this->loadedConfigurations[$name] = TRUE;
|
|
|
|
$path = $this->getConfigurationPath($name, FALSE);
|
|
|
|
if($path) {
|
|
$this->make('config')->set($name, require $path);
|
|
}
|
|
|
|
$path = $this->getConfigurationPath($name, TRUE);
|
|
|
|
if($path) {
|
|
$this->app['config']->set(
|
|
$name,
|
|
array_merge(
|
|
$this->app['config']->get($name, []),
|
|
require $path
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Register the aliases for the application.
|
|
*
|
|
* @param array $userAliases
|
|
* @return void
|
|
*/
|
|
public function withAliases($userAliases = [])
|
|
{
|
|
$defaults = [
|
|
'Illuminate\Support\Facades\Auth' => 'Auth',
|
|
// 'Illuminate\Support\Facades\Cache' => 'Cache',
|
|
'Illuminate\Support\Facades\DB' => 'DBLumen',
|
|
'Illuminate\Support\Facades\Event' => 'Event',
|
|
'Illuminate\Support\Facades\Gate' => 'Gate',
|
|
'Illuminate\Support\Facades\Log' => 'Log',
|
|
'Illuminate\Support\Facades\Queue' => 'Queue',
|
|
'Illuminate\Support\Facades\Schema' => 'Schema',
|
|
'Illuminate\Support\Facades\URL' => 'URL',
|
|
'Illuminate\Support\Facades\Validator' => 'Validator',
|
|
];
|
|
|
|
if (! static::$aliasesRegistered) {
|
|
static::$aliasesRegistered = true;
|
|
|
|
$merged = array_merge($defaults, $userAliases);
|
|
|
|
foreach ($merged as $original => $alias) {
|
|
class_alias($original, $alias);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function getConfigurationPath($name = NULL, $only_defaults = NULL) {
|
|
if(!isset($this->lumen_path)) {
|
|
global $composer_autoloader;
|
|
$this->lumen_path = dirname(realpath($composer_autoloader->findFile(BaseApplication::class)));
|
|
}
|
|
|
|
if(!$name) {
|
|
$appConfigDir = $this->basePath('config').'/';
|
|
|
|
if(
|
|
file_exists($appConfigDir)
|
|
&& $only_defaults !== FALSE
|
|
) {
|
|
return $appConfigDir;
|
|
} elseif(
|
|
file_exists($path = $this->lumen_path.'/../config/')
|
|
&& !$only_defaults
|
|
) {
|
|
return $path;
|
|
}
|
|
} else {
|
|
$appConfigPath = $this->basePath('config').'/'.$name.'.php';
|
|
|
|
if(
|
|
file_exists($appConfigPath)
|
|
&& $only_defaults !== FALSE
|
|
) {
|
|
return $appConfigPath;
|
|
} elseif(
|
|
file_exists($path = $this->lumen_path.'/../config/'.$name.'.php')
|
|
&& !$only_defaults
|
|
) {
|
|
return $path;
|
|
}
|
|
}
|
|
}
|
|
}
|