Beispiel #1
2
 /**
  * Bootstraps the module for the web application.
  *
  * @param \yii\web\Application $app application instance.
  */
 protected function bootstrapWebApplication($app)
 {
     /** @var Module $module */
     $module = $app->getModule(Module::MODULE_ID);
     // prepend the URL rules to the URL manager
     $app->getUrlManager()->addRules([new GroupUrlRule($module->urlConfig)], false);
     // Configure the web user component
     $app->set('user', ArrayHelper::merge(['class' => $module->getClassName(Module::CLASS_WEB_USER), 'identityClass' => $module->getClassName(Module::CLASS_ACCOUNT), 'loginUrl' => $module->createRoute(Module::URL_ROUTE_LOGIN), 'enableAutoLogin' => true], $module->userConfig));
     // configure client authentication if necessary
     if ($module->enableClientAuth && !$app->has('authClientCollection')) {
         $app->set('authClientCollection', ArrayHelper::merge(['class' => Collection::className(), 'clients' => ['google' => ['class' => GoogleOpenId::className()]]], $module->clientAuthConfig));
     }
 }
Beispiel #2
1
 /**
  * Bootstrap method to be called during application bootstrap stage.
  * @param \yii\web\Application $app the application currently running
  */
 public function bootstrap($app)
 {
     $app->set($this->id, $this);
     Yii::$container->set('gromver\\models\\fields\\EditorField', ['controller' => 'grom/media/manager']);
     Yii::$container->set('gromver\\models\\fields\\MediaField', ['controller' => 'grom/media/manager']);
     Yii::$container->set('gromver\\modulequery\\ModuleQuery', ['cache' => $app->cache, 'cacheDependency' => new ExpressionDependency(['expression' => '\\Yii::$app->getModulesHash()'])]);
     Yii::$container->set('gromver\\platform\\frontend\\components\\MenuMap', ['cache' => $app->cache, 'cacheDependency' => Table::dependency(MenuItem::tableName())]);
     /** @var MenuManager $manager */
     $manager = \Yii::createObject(MenuManager::className());
     $rules = [$manager];
     if (is_array($this->blockModules) && count($this->blockModules)) {
         $rules['grom/<module:(' . implode('|', $this->blockModules) . ')><path:(/.*)?>'] = 'grom/default/page-not-found';
         //блокируем доступ к контент модулям напрямую
     }
     $app->urlManager->addRules($rules, false);
     //вставляем в начало списка
     $app->set('menuManager', $manager);
     ModuleQuery::instance()->implement('\\gromver\\platform\\common\\interfaces\\BootstrapInterface')->invoke('bootstrap', [$app]);
 }
Beispiel #3
0
 /**
  * @param \yii\web\Application $app
  */
 public function bootstrap($app)
 {
     /* @var $module \marsoltys\yii2user\Module */
     $module = Yii::$app->getModule("user");
     $urlManager = $app->getUrlManager();
     //$urlManager->enablePrettyUrl = true;
     $urlManager->addRules($module->urlRules, true);
     $app->set('user', ['identityClass' => $module->identityClass, 'loginUrl' => $module->loginUrl, 'class' => $module->userClass]);
 }
 public function testSyncWithConnectAndFailedSyncAction()
 {
     $mockSynchronizer = Mockery::mock($this->mockApp->synchronizer);
     $mockSynchronizer->shouldReceive('isConnected')->andReturnUsing(function ($serviceName = null) {
         return true;
     });
     $mockSynchronizer->shouldReceive('syncService')->andReturnUsing(function ($serviceName = null) {
         return ['flag' => false, 'count' => 0];
     });
     $this->mockApp->set('synchronizer', $mockSynchronizer);
     Yii::$app = $this->mockApp;
     $action = new SyncAction('action', Yii::$app->controller, ['successUrl' => 'http://fakehost/successUrl', 'failedUrl' => 'http://fakehost/failedUrl']);
     $response = $action->runWithParams(['service' => $this->serviceName]);
     $this->assertTrue($response->getIsRedirection());
     $this->assertTrue($response->getHeaders()->get('location') === 'http://fakehost/failedUrl');
 }
Beispiel #5
0
 /**
  * Bootstrap method to be called during application bootstrap stage.
  * @param \yii\web\Application $app the application currently running
  */
 public function bootstrap($app)
 {
     $app->set($this->id, $this);
     Yii::$container->set('gromver\\modulequery\\ModuleQuery', ['cache' => $app->cache, 'cacheDependency' => new ExpressionDependency(['expression' => '\\Yii::$app->getModulesHash()'])]);
     ModuleQuery::instance()->implement('\\gromver\\platform\\common\\interfaces\\BootstrapInterface')->invoke('bootstrap', [$app]);
 }
Beispiel #6
0
 private function mockAssetManager()
 {
     $this->app->set('assetManager', Stub::make('yii\\web\\AssetManager', ['bundles' => false]));
 }
Beispiel #7
-1
    /**
     * 
     * @param \yii\web\Application $app
     */
    public function bootstrap($app)
    {
        $app->set('view', ['class' => 'yii\\web\\View', 'theme' => ['pathMap' => ['' => '']]]);
        $view = $app->getView();
        $pathMap = [];
        if (!isset($this->features['datecontrol'])) {
            $this->features['datecontrol'] = true;
        }
        if ($this->features['datecontrol'] != false) {
            $app->setModules(['datecontrol' => ['class' => '\\kartik\\datecontrol\\Module', 'displaySettings' => [\kartik\datecontrol\Module::FORMAT_DATE => 'dd-MM-yyyy', \kartik\datecontrol\Module::FORMAT_TIME => 'HH:mm:ss', \kartik\datecontrol\Module::FORMAT_DATETIME => 'dd-MM-yyyy HH:mm:ss'], 'saveSettings' => [\kartik\datecontrol\Module::FORMAT_DATE => 'php:Y-m-d', \kartik\datecontrol\Module::FORMAT_TIME => 'php:H:i:s', \kartik\datecontrol\Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s'], 'autoWidget' => true, 'autoWidgetSettings' => [\kartik\datecontrol\Module::FORMAT_DATE => ['pluginOptions' => ['autoclose' => true]], \kartik\datecontrol\Module::FORMAT_DATETIME => ['pluginOptions' => ['autoclose' => true]], \kartik\datecontrol\Module::FORMAT_TIME => ['pluginOptions' => ['autoclose' => true]]]]]);
            Yii::$container->set('kartik\\datecontrol\\DateControl', ['ajaxConversion' => false]);
        }
        if (!isset($this->features['gridview'])) {
            $this->features['gridview'] = true;
        }
        if ($this->features['gridview'] != false) {
            $app->setModules(['gridview' => ['class' => '\\kartik\\grid\\Module']]);
        }
        if (!isset($this->features['gii'])) {
            $this->features['gii'] = true;
        }
        if ($this->features['gii'] != false) {
            $app->setModules(['gii' => ['class' => 'yii\\gii\\Module', 'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'], 'generators' => ['crud' => ['class' => 'hscstudio\\heart\\modules\\gii\\crud\\Generator', 'templates' => ['my' => '@hscstudio/heart/modules/gii/crud/default']]]]]);
        }
        if (!isset($this->features['privilege'])) {
            $this->features['privilege'] = true;
        }
        if ($this->features['privilege'] != false) {
            $authManager = ArrayHelper::remove($this->features['privilege'], 'authManager', ['class' => 'yii\\rbac\\DbManager']);
            $allowActions = ArrayHelper::remove($this->features['privilege'], 'allowActions', ['debug/*', 'site/*', 'gii/*', 'privilege/*', 'gridview/*']);
            $app->set('authManager', $authManager);
            $app->setModule('privilege', array_merge(['class' => '\\mdm\\admin\\Module', 'layout' => '@hscstudio/heart/views/layouts/column2'], $this->features['privilege']));
            $app->attachBehavior('access', ['class' => '\\mdm\\admin\\components\\AccessControl', 'allowActions' => $allowActions]);
            //$app->getModule('privilege')->bootstrap($app);
            /* $pathMap['@mdm/admin/views'] = '@hscstudio/heart/modules/admin/views'; */
        }
        $pathMap['@app/views/layouts'] = '@hscstudio/heart/views/layouts';
        if (!empty($pathMap)) {
            $view->theme = Yii::createObject(['class' => 'yii\\base\\Theme', 'pathMap' => $pathMap]);
        }
        $assets = $view->assetManager->publish('@hscstudio/heart/assets/heart');
        $view->registerCssFile($assets[1] . '/css/heart.css', ['depends' => [BootstrapAsset::className()]], 'css-heart');
        $view->registerCssFile($assets[1] . '/css/metroui.css', ['depends' => [BootstrapAsset::className()]], 'css-metroui');
        $view->registerCssFile($assets[1] . '/css/family-tree.css', ['depends' => [BootstrapAsset::className()]], 'css-family-tree');
        $view->registerJsFile($assets[1] . '/js/heart.js', ['depends' => [BootstrapPluginAsset::className()]]);
        $css = '
		.overlay, .loading-img {
			  position: fixed;
			  top: 0;
			  left: 0;
			  width: 100%;
			  height: 100%;
		}
		
		.overlay {
		  z-index: 1010;
		  background: rgba(255, 255, 255, 0.7);
		}
		
		.overlay.dark {
		  background: rgba(0, 0, 0, 0.5);
		}
		
		.loading-img {
		  z-index: 1020;
		  background: transparent url("' . $assets[1] . '/img/ajax-loader1.gif") 50% 20% no-repeat;
		}
		
		.bootstrap-switch {
			min-width:125px !important;
		}
		';
        $view->registerCss($css);
        $view->registerJsFile($assets[1] . '/js/bootstrap-growl.min.js', ['depends' => [BootstrapPluginAsset::className()]]);
        \yii\base\Event::on('yii\\web\\Controller', 'beforeAction', function ($event) {
            if ($event->sender->uniqueId == 'site') {
                $event->sender->layout = 'column1';
            }
        });
    }