|
- <?php
-
-
-
- use common\components\BusinessLogic;
- use common\components\DolibarrApi;
- use common\components\ForumFlarumClient;
- use domain\Distribution\Distribution\Distribution;
- use domain\Document\DeliveryNote\DeliveryNote;
- use domain\Order\Order\Order;
- use domain\Payment\Payment;
- use domain\Producer\Producer\Producer;
- use domain\Product\Product\Product;
- use domain\Ticket\Ticket\Ticket;
- use domain\Ticket\TicketMessage\TicketMessage;
- use domain\User\User\User;
-
- $serverName = isset($_SERVER['SERVER_NAME']) ?? '' ;
-
- return [
- 'bootstrap' => ['listener'],
- 'aliases' => [
- '@bower' => '@vendor/bower-asset',
- ],
- 'vendorPath' => dirname(__DIR__, 2) . '/vendor',
- 'on beforeRequest' => function () {
- if (method_exists(Yii::$app->request, 'getAbsoluteUrl')) {
- $url = Yii::$app->request->getAbsoluteUrl();
- if ($_SERVER['SERVER_NAME'] != 'localhost' && !empty($url) && substr($url, -1) == '/' && substr($url, -5) != '.net/' && substr($url, -4) != '.fr/') {
- $url = substr($url, 0, strlen($url) - 1);
- Yii::$app->getResponse()->redirect($url, 301);
- Yii::$app->end();
- }
- }
-
- if (Yii::$app->params['maintenanceMode'] && Yii::$app instanceof \yii\web\Application) {
- if(isset($_GET['letMeIn'])) {
- Yii::$app->session->set('letMeIn', (int) $_GET['letMeIn']);
- }
- $letMeIn = Yii::$app->session['letMeIn'];
- if (!$letMeIn) {
- Yii::$app->catchAll = ['site/maintenance'];
- }
- }
- },
- 'components' => [
- 'faker' => [
- 'class' => 'common\components\Faker'
- ],
- 'parameterBag' => [
- 'class' => 'common\components\ParameterBag'
- ],
- 'pageSizer' => [
- 'class' => 'common\components\PageSizer'
- ],
- 'alwaysdataClient' => [
- 'class' => 'common\components\AlwaysdataClient'
- ],
- 'forumFlarumClient' => function() {
-
- return new ForumFlarumClient(Yii::$app->logic->getSettingModule()->getAdminSettingBag()->get('forumFlarumUrl').'api/');
- },
- 'dolibarrApi' => function() {
- return new DolibarrApi(
- Yii::$app->parameterBag->get('dolibarrApiUrl'),
- ['DOLAPIKEY', \Yii::$app->parameterBag->get('dolibarrApiKey')]
- );
- },
- 'assetManager' => [
- 'linkAssets' => YII_ENV == "dev" ? 'true' : false,
- ],
- 'user' => [
- 'class' => 'yii\web\User',
- 'identityClass' => 'domain\User\User\User',
- 'enableAutoLogin' => true,
- 'identityCookie' => [
- 'name' => 'distrib',
- 'domain' => (($serverName != 'localhost') ? '.' : '') . Yii::getAlias('@domainName'),
- 'path' => '/',
- ]
- ],
- 'session' => [
- 'class' => 'yii\web\Session',
- 'name' => 'PHPDISTRIBSESSID',
- 'cookieParams' => [
- 'domain' => (($serverName != 'localhost') ? '.' : '') . Yii::getAlias('@domainName'),
- 'httpOnly' => true,
- ],
- ],
- 'cache' => [
- 'class' => 'yii\caching\FileCache',
- ],
- 'image' => [
- 'class' => 'yii\image\ImageDriver',
- 'driver' => 'GD',
- ],
- 'mailerService' => [
- 'class' => 'common\components\MailerService'
- ],
- 'bulkMailer' => [
- 'class' => 'common\components\BulkMailer\BulkMailerProxy'
- ],
- 'view' => [
- 'class' => 'yii\web\View',
- 'renderers' => [
- 'twig' => [
- 'class' => 'yii\twig\ViewRenderer',
- 'cachePath' => '@runtime/Twig/cache',
- 'options' => [
- 'auto_reload' => true,
- ],
- 'globals' => [
- 'html' => ['class' => '\yii\helpers\Html'],
- ],
- 'uses' => ['yii\bootstrap'],
- ],
- ],
- ],
- 'urlManagerProducer' => [
- 'class' => 'producer\components\UrlManagerProducer',
- 'subDomain' => Yii::getAlias('@producerSubdomain'),
- 'domainName' => Yii::getAlias('@domainName'),
- 'baseUrl' => Yii::getAlias('@baseUrl') . Yii::getAlias('@baseUrlProducer'),
- 'enablePrettyUrl' => true,
- 'showScriptName' => false,
- 'enableStrictParsing' => false,
- 'rules' => [
- '<slug_producer:\w+>' => 'site/index',
- '<slug_producer:\w+>/<controller>/<action>' => '<controller>/<action>',
- ],
- 'normalizer' => [
- 'class' => 'yii\web\UrlNormalizer',
- ],
- ],
- 'urlManagerFrontend' => [
- 'class' => 'common\components\UrlManagerCommon',
- 'subDomain' => Yii::getAlias('@frontendSubdomain'),
- 'domainName' => Yii::getAlias('@domainName'),
- 'baseUrl' => Yii::getAlias('@baseUrl') . Yii::getAlias('@baseUrlFrontend'),
- 'enablePrettyUrl' => true,
- 'showScriptName' => false,
- 'enableStrictParsing' => false,
- 'rules' => [
- ],
- ],
- 'urlManagerBackend' => [
- 'class' => 'common\components\UrlManagerCommon',
- 'subDomain' => Yii::getAlias('@backendSubdomain'),
- 'domainName' => Yii::getAlias('@domainName'),
- 'baseUrl' => Yii::getAlias('@baseUrl') . Yii::getAlias('@baseUrlBackend'),
- 'enablePrettyUrl' => true,
- 'showScriptName' => false,
- 'enableStrictParsing' => false,
- 'rules' => [],
- ],
- 'logic' => function () {
- return new BusinessLogic();
- },
- 'listener' => [
- 'class' => \justcoded\yii2\eventlistener\components\EventListener::class,
- 'listeners' => [],
- 'observers' => [
- User::class => [
-
- domain\Producer\Producer\Event\UserObserver::class
- ],
- Order::class => [
-
- domain\Payment\Event\OrderObserver::class
- ],
- Payment::class => [
-
- domain\User\UserProducer\Event\PaymentObserver::class
- ],
- Distribution::class => [
-
- domain\Subscription\Subscription\Event\DistributionObserver::class
- ],
- DeliveryNote::class => [
-
- domain\Order\Order\Event\DeliveryNoteObserver::class,
-
- domain\Document\DeliveryNote\Event\DeliveryNoteObserver::class
- ],
- Product::class => [
-
- domain\Subscription\Subscription\Event\ProductObserver::class
- ],
- Ticket::class => [
-
- \domain\Ticket\Ticket\Event\TicketObserver::class,
- ],
- TicketMessage::class => [
-
- \domain\Ticket\TicketMessage\Event\TicketMessageObserver::class,
- ],
- Producer::class => [
-
- domain\Producer\Producer\Event\ProducerObserver::class
- ]
- ],
- ],
- ],
- 'language' => 'fr-FR',
- 'timeZone' => 'Europe/Paris',
- ];
|