¨4.0.1¨
This commit is contained in:
@@ -6,8 +6,16 @@ use Exception;
|
||||
use Modules\Support\Locale;
|
||||
use Modules\Setting\Entities\Setting;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use FleetCart\Http\Middleware\LicenseChecker;
|
||||
use Modules\Core\Http\Middleware\Authenticate;
|
||||
use Modules\Core\Http\Middleware\Authorization;
|
||||
use Modules\Core\Http\Middleware\GuestMiddleware;
|
||||
use Modules\Core\Http\Middleware\AdminMiddleware;
|
||||
use Modules\Setting\Repository as SettingRepository;
|
||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
use Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect;
|
||||
use Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes;
|
||||
use Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter;
|
||||
|
||||
class CoreServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -17,15 +25,17 @@ class CoreServiceProvider extends ServiceProvider
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
'auth' => \Modules\Core\Http\Middleware\Authenticate::class,
|
||||
'admin' => \Modules\Core\Http\Middleware\AdminMiddleware::class,
|
||||
'guest' => \Modules\Core\Http\Middleware\GuestMiddleware::class,
|
||||
'can' => \Modules\Core\Http\Middleware\Authorization::class,
|
||||
'localize' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes::class,
|
||||
'locale_session_redirect' => \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect::class,
|
||||
'localization_redirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class,
|
||||
'auth' => Authenticate::class,
|
||||
'admin' => AdminMiddleware::class,
|
||||
'licensed' => LicenseChecker::class,
|
||||
'guest' => GuestMiddleware::class,
|
||||
'can' => Authorization::class,
|
||||
'localize' => LaravelLocalizationRoutes::class,
|
||||
'locale_session_redirect' => LocaleSessionRedirect::class,
|
||||
'localization_redirect' => LaravelLocalizationRedirectFilter::class,
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
@@ -33,7 +43,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
if (! config('app.installed')) {
|
||||
if (!config('app.installed')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,6 +59,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
$this->blacklistAdminRoutesOnFrontend();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setup supported locales.
|
||||
*
|
||||
@@ -65,6 +76,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
$this->app['config']->set('laravellocalization.supportedLocales', $supportedLocales);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get supported locales from database.
|
||||
*
|
||||
@@ -79,17 +91,6 @@ class CoreServiceProvider extends ServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide default locale in url for non multi-locale mode.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function hideDefaultLocaleInURL()
|
||||
{
|
||||
if (! is_multilingual()) {
|
||||
$this->app['config']->set('laravellocalization.hideDefaultLocaleInURL', true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register setting binding.
|
||||
@@ -103,6 +104,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setup application locale.
|
||||
*
|
||||
@@ -118,6 +120,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
LaravelLocalization::setLocale($locale);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setup application cache driver.
|
||||
*
|
||||
@@ -128,6 +131,20 @@ class CoreServiceProvider extends ServiceProvider
|
||||
$this->app['config']->set('cache.default', config('app.cache') ? 'file' : 'array');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hide default locale in url for non multi-locale mode.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function hideDefaultLocaleInURL()
|
||||
{
|
||||
if (!is_multilingual()) {
|
||||
$this->app['config']->set('laravellocalization.hideDefaultLocaleInURL', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setup application timezone.
|
||||
*
|
||||
@@ -142,6 +159,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
$this->app['config']->set('app.timezone', $timezone);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setup application mail config.
|
||||
*
|
||||
@@ -159,6 +177,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
$this->app['config']->set('mail.mailers.smtp.encryption', setting('mail_encryption'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register the filters.
|
||||
*
|
||||
@@ -171,6 +190,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register inAdminPanel state to the IoC container.
|
||||
*
|
||||
@@ -189,6 +209,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
$this->app['inAdminPanel'] = $this->app['request']->segment($index) === 'admin';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Blacklist admin routes on frontend for ziggy package.
|
||||
*
|
||||
@@ -196,7 +217,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
*/
|
||||
private function blacklistAdminRoutesOnFrontend()
|
||||
{
|
||||
if (! $this->app['inAdminPanel']) {
|
||||
if (!$this->app['inAdminPanel']) {
|
||||
$this->app['config']->set('ziggy.blacklist', ['admin.*']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,12 @@ class ModuleServiceProvider extends ServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load views for the given module.
|
||||
*
|
||||
* @param \Nwidart\Modules\Module $module
|
||||
* @param Module $module
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function loadViews(Module $module)
|
||||
@@ -35,10 +37,12 @@ class ModuleServiceProvider extends ServiceProvider
|
||||
$this->loadViewsFrom("{$module->getPath()}/Resources/views", $module->get('alias'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load translations for the given module.
|
||||
*
|
||||
* @param \Nwidart\Modules\Module $module
|
||||
* @param Module $module
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function loadTranslations(Module $module)
|
||||
@@ -46,17 +50,18 @@ class ModuleServiceProvider extends ServiceProvider
|
||||
$this->loadTranslationsFrom("{$module->getPath()}/Resources/lang", $module->get('alias'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load migrations for the given module.
|
||||
*
|
||||
* @param \Nwidart\Modules\Module $module
|
||||
* @param Module $module
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function loadConfigs(Module $module)
|
||||
{
|
||||
collect([
|
||||
'config' => "{$module->getPath()}/Config/config.php",
|
||||
'assets' => "{$module->getPath()}/Config/assets.php",
|
||||
'permissions' => "{$module->getPath()}/Config/permissions.php",
|
||||
])->filter(function ($path) {
|
||||
return file_exists($path);
|
||||
@@ -65,10 +70,12 @@ class ModuleServiceProvider extends ServiceProvider
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load migrations for the given module.
|
||||
*
|
||||
* @param \Nwidart\Modules\Module $module
|
||||
* @param Module $module
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function loadMigrations(Module $module)
|
||||
@@ -76,10 +83,12 @@ class ModuleServiceProvider extends ServiceProvider
|
||||
$this->loadMigrationsFrom("{$module->getPath()}/Database/Migrations");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load model factories for the given module.
|
||||
*
|
||||
* @param \Nwidart\Modules\Module $module
|
||||
* @param Module $module
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function loadModelFactories(Module $module)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Modules\Core\Providers;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
@@ -10,8 +11,6 @@ class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
@@ -21,6 +20,7 @@ class RouteServiceProvider extends ServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Map routes from all enabled modules.
|
||||
*
|
||||
@@ -37,6 +37,79 @@ class RouteServiceProvider extends ServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Group routes to common prefix and middleware.
|
||||
*
|
||||
* @param string $namespace
|
||||
* @param Closure $callback
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function groupRoutes($namespace, $callback)
|
||||
{
|
||||
Route::group([
|
||||
'namespace' => $namespace,
|
||||
'prefix' => LaravelLocalization::setLocale(),
|
||||
'middleware' => ['localize', 'locale_session_redirect', 'localization_redirect', 'web'],
|
||||
], function () use ($callback) {
|
||||
$callback();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Map admin routes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function mapAdminRoutes($path)
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Route::group([
|
||||
'namespace' => 'Admin',
|
||||
'prefix' => 'admin',
|
||||
'middleware' => ['admin', 'licensed'],
|
||||
], function () use ($path) {
|
||||
require_once $path;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Map public routes.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function mapPublicRoutes($path)
|
||||
{
|
||||
if (file_exists($path)) {
|
||||
require_once $path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function mapApiRoutes($path)
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Route::group([
|
||||
'namespace' => 'Api',
|
||||
'prefix' => 'api',
|
||||
'middleware' => ['api'],
|
||||
], function () use ($path) {
|
||||
require_once $path;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Map routes from active theme.
|
||||
*
|
||||
@@ -52,70 +125,4 @@ class RouteServiceProvider extends ServiceProvider
|
||||
$this->mapApiRoutes("{$theme->getPath()}/routes/api.php");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Group routes to common prefix and middleware.
|
||||
*
|
||||
* @param string $namespace
|
||||
* @param \Closure $callback
|
||||
* @return void
|
||||
*/
|
||||
private function groupRoutes($namespace, $callback)
|
||||
{
|
||||
Route::group([
|
||||
'namespace' => $namespace,
|
||||
'prefix' => LaravelLocalization::setLocale(),
|
||||
'middleware' => ['localize', 'locale_session_redirect', 'localization_redirect', 'web'],
|
||||
], function () use ($callback) {
|
||||
$callback();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Map admin routes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function mapAdminRoutes($path)
|
||||
{
|
||||
if (! file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Route::group([
|
||||
'namespace' => 'Admin',
|
||||
'prefix' => 'admin',
|
||||
'middleware' => ['admin'],
|
||||
], function () use ($path) {
|
||||
require_once $path;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Map public routes.
|
||||
*
|
||||
* @param string $path
|
||||
* @return void
|
||||
*/
|
||||
private function mapPublicRoutes($path)
|
||||
{
|
||||
if (file_exists($path)) {
|
||||
require_once $path;
|
||||
}
|
||||
}
|
||||
|
||||
private function mapApiRoutes($path)
|
||||
{
|
||||
if (! file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Route::group([
|
||||
'namespace' => 'Api',
|
||||
'prefix' => 'api',
|
||||
'middleware' => ['api'],
|
||||
], function () use ($path) {
|
||||
require_once $path;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class SearchEngineServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
if (! config('app.installed')) {
|
||||
if (!config('app.installed')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class ThemeServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
if (! config('app.installed')) {
|
||||
if (!config('app.installed')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,10 +30,12 @@ class ThemeServiceProvider extends ServiceProvider
|
||||
$this->bootTheme($this->app['stylist']->get($activeTheme));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Boot the given theme.
|
||||
*
|
||||
* @param \Mehedi\Stylist\Theme\Theme $theme
|
||||
* @param Theme $theme
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function bootTheme(Theme $theme)
|
||||
@@ -50,10 +52,12 @@ class ThemeServiceProvider extends ServiceProvider
|
||||
$this->requireFiles($theme, $files);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register given service providers.
|
||||
*
|
||||
* @param array $providers
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function registerProviders($providers = [])
|
||||
@@ -63,11 +67,13 @@ class ThemeServiceProvider extends ServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load translations for the given theme.
|
||||
*
|
||||
* @param string $themeAlias
|
||||
* @param \Mehedi\Stylist\Theme\Theme $theme
|
||||
* @param Theme $theme
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function loadTranslations(Theme $theme, $themeAlias)
|
||||
@@ -75,11 +81,13 @@ class ThemeServiceProvider extends ServiceProvider
|
||||
$this->loadTranslationsFrom("{$theme->getPath()}/resources/lang", $themeAlias);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load configs for the given theme.
|
||||
*
|
||||
* @param string $themeAlias
|
||||
* @param \Mehedi\Stylist\Theme\Theme $theme
|
||||
* @param Theme $theme
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function loadConfigs(Theme $theme, $themeAlias)
|
||||
@@ -95,11 +103,13 @@ class ThemeServiceProvider extends ServiceProvider
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Require the given files.
|
||||
*
|
||||
* @param \Mehedi\Stylist\Theme\Theme $theme
|
||||
* @param Theme $theme
|
||||
* @param array $files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function requireFiles(Theme $theme, $files = [])
|
||||
|
||||
Reference in New Issue
Block a user