openclassify/addons/default/visiosoft/default-theme/src/DefaultThemeServiceProvider.php
2019-09-07 14:30:49 +03:00

188 lines
4.4 KiB
PHP

<?php namespace Visiosoft\DefaultTheme;
use Anomaly\Streams\Platform\Addon\AddonServiceProvider;
use Illuminate\Routing\Router;
class DefaultThemeServiceProvider extends AddonServiceProvider
{
/**
* Additional addon plugins.
*
* @type array|null
*/
protected $plugins = [];
/**
* The addon Artisan commands.
*
* @type array|null
*/
protected $commands = [];
/**
* The addon's scheduled commands.
*
* @type array|null
*/
protected $schedules = [];
/**
* The addon API routes.
*
* @type array|null
*/
protected $api = [];
/**
* The addon routes.
*
* @type array|null
*/
protected $routes = [
'login' => [
'as' => 'stream::login-route',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@login',
],
'register' => [
'as' => 'stream::register-route',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@register',
],
'users/password/forgot' => 'Visiosoft\AdvsModule\Http\Controller\advsController@passwordForgot',
'users/password/reset' => 'Visiosoft\AdvsModule\Http\Controller\advsController@passwordReset',
'authcheck' => 'Visiosoft\AdvsModule\Http\Controller\advsController@authCheck',
'isactive/{slug}' => 'Visiosoft\AdvsModule\Http\Controller\advsController@isActiveJson',
];
/**
* The addon middleware.
*
* @type array|null
*/
protected $middleware = [
//Visiosoft\DefaultTheme\Http\Middleware\ExampleMiddleware::class
];
/**
* Addon group middleware.
*
* @var array
*/
protected $groupMiddleware = [
//'web' => [
// Visiosoft\DefaultTheme\Http\Middleware\ExampleMiddleware::class,
//],
];
/**
* Addon route middleware.
*
* @type array|null
*/
protected $routeMiddleware = [];
/**
* The addon event listeners.
*
* @type array|null
*/
protected $listeners = [
//Visiosoft\DefaultTheme\Event\ExampleEvent::class => [
// Visiosoft\DefaultTheme\Listener\ExampleListener::class,
//],
];
/**
* The addon alias bindings.
*
* @type array|null
*/
protected $aliases = [
//'Example' => Visiosoft\DefaultTheme\Example::class
];
/**
* The addon class bindings.
*
* @type array|null
*/
protected $bindings = [];
/**
* The addon singleton bindings.
*
* @type array|null
*/
protected $singletons = [];
/**
* Additional service providers.
*
* @type array|null
*/
protected $providers = [
//\ExamplePackage\Provider\ExampleProvider::class
];
/**
* The addon view overrides.
*
* @type array|null
*/
protected $overrides = [
'streams::errors/404' => 'theme::errors/404',
'streams::errors/500' => 'theme::errors/500',
'streams::errors/403' => 'theme::errors/403',
//'streams::errors/404' => 'module::errors/404',
//'streams::errors/500' => 'module::errors/500',
];
/**
* The addon mobile-only view overrides.
*
* @type array|null
*/
protected $mobile = [
//'streams::errors/404' => 'module::mobile/errors/404',
//'streams::errors/500' => 'module::mobile/errors/500',
];
/**
* Register the addon.
*/
public function register()
{
// Run extra pre-boot registration logic here.
// Use method injection or commands to bring in services.
}
/**
* Boot the addon.
*/
public function boot()
{
view()->composer('*', function ($view) {
if (Request()->session()->get('_locale') === null) {
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
$acceptLang = ['ar', 'de', 'el', 'en', 'es', 'fa', 'fr', 'it', 'nl', 'pt', 'ru', 'tr'];
$lang = in_array($lang, $acceptLang) ? $lang : 'en';
App()->setLocale($lang);
Request()->session()->put('_locale', $lang);
}
});
}
/**
* Map additional addon routes.
*
* @param Router $router
*/
public function map(Router $router)
{
// Register dynamic routes here for example.
// Use method injection or commands to bring in services.
}
}