Exemplo n.º 1
0
 public function bootstrap($app)
 {
     /** @var Module $module */
     if ($app->hasModule('cms') && ($module = $app->getModule('cms')) instanceof Module) {
         $classMap = array_merge($this->classMap, $module->classMap);
         foreach (array_keys($this->classMap) as $item) {
             $className = '\\nullref\\cms\\models\\' . $item;
             $cmsClass = $className::className();
             $definition = $classMap[$item];
             Yii::$container->set($cmsClass, $definition);
         }
         if ($app instanceof WebApplication) {
             $prefix = $app->getModule('cms')->urlPrefix;
             $app->urlManager->addRules([Yii::createObject(['class' => PageUrlRule::className(), 'pattern' => $prefix . '/<route:[_a-zA-Z0-9-/]+>'])]);
             if (!isset($app->controllerMap['elfinder-backend'])) {
                 $app->controllerMap['elfinder-backend'] = ['class' => 'mihaildev\\elfinder\\Controller', 'user' => 'admin', 'access' => ['@'], 'disabledCommands' => ['netmount'], 'roots' => [['path' => 'uploads', 'name' => 'Uploads']]];
             }
             $app->i18n->translations['cms*'] = ['class' => PhpMessageSource::className(), 'basePath' => '@nullref/cms/messages'];
         }
         if (YII_ENV_DEV) {
             Event::on(Gii::className(), Gii::EVENT_BEFORE_ACTION, function (Event $event) {
                 /** @var Gii $gii */
                 $gii = $event->sender;
                 $gii->generators['block-migration-generator'] = ['class' => 'nullref\\cms\\generators\\block_migration\\Generator'];
                 $gii->generators['block-generator'] = ['class' => 'nullref\\cms\\generators\\block\\Generator'];
                 $gii->generators['pages-migration-generator'] = ['class' => 'nullref\\cms\\generators\\pages_migration\\Generator'];
             });
         }
     }
 }
Exemplo n.º 2
0
 public function init()
 {
     parent::init();
     if (\Yii::$app->cms->giiEnabled == Cms::BOOL_N) {
         $this->allowedIPs = [""];
     } else {
         //TODO:add merge settings
         $this->allowedIPs = explode(",", \Yii::$app->cms->giiAllowedIPs);
     }
     $class = new \ReflectionClass(\yii\gii\Module::className());
     $dir = dirname($class->getFileName());
     $this->setBasePath($dir);
 }
Exemplo n.º 3
0
 /**
  * Bootstrap method to be called during application bootstrap stage.
  * @param Application $app the application currently running
  */
 public function bootstrap($app)
 {
     if ($app instanceof WebApplication) {
     }
     if ($app instanceof ConsoleApplication) {
         $app->controllerMap['module'] = ['class' => 'nullref\\core\\console\\ModuleController'];
         $app->controllerMap['modules-migrate'] = ['class' => 'nullref\\core\\console\\ModulesMigrateController'];
         $app->controllerMap['env'] = ['class' => 'nullref\\core\\console\\EnvController'];
         $app->getModule('core')->controllerMap['migrate'] = ['class' => 'nullref\\core\\console\\MigrateController'];
     }
     if (YII_ENV_DEV && class_exists('yii\\gii\\Module')) {
         Event::on(Gii::className(), Gii::EVENT_BEFORE_ACTION, function (Event $event) {
             /** @var Gii $gii */
             $gii = $event->sender;
             $gii->generators['relation-migration'] = ['class' => 'nullref\\core\\generators\\migration\\Generator'];
         });
     }
 }
Exemplo n.º 4
0
<?php

$params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
return ['id' => 'app-backend', 'name' => 'Toyplan Admin', 'basePath' => dirname(__DIR__), 'controllerNamespace' => 'backend\\controllers', 'bootstrap' => ['log'], 'modules' => ['gii' => ['class' => \yii\gii\Module::className(), 'allowedIPs' => ['*']], 'gridview' => ['class' => '\\kartik\\grid\\Module']], 'components' => ['request' => ['class' => 'common\\components\\Request', 'web' => '/backend/web', 'adminUrl' => '/admin'], 'urlManager' => ['class' => 'yii\\web\\UrlManager', 'enablePrettyUrl' => true, 'showScriptName' => false, 'enableStrictParsing' => false, 'rules' => ['' => 'site/index', ['pattern' => '<slug>', 'route' => 'category/index', 'suffix' => '/'], '<module:\\w+>/<controller:\\w+>/<action:[\\w\\-]+>' => '<module>/<controller>/<action>']], 'user' => ['identityClass' => 'common\\models\\User', 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error']], 'params' => $params];
Exemplo n.º 5
0
<?php

$params = (require __DIR__ . '/params.php');
$config = ['id' => 'basic', 'language' => 'ru', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'components' => ['request' => ['cookieValidationKey' => 'O_RRcy_Mh_JvD8bbXBooCDZtZwNjRLYn'], 'cache' => ['class' => 'yii\\caching\\FileCache'], 'user' => ['identityClass' => 'app\\models\\User', 'enableAutoLogin' => true], 'errorHandler' => ['errorAction' => 'site/error'], 'mailer' => ['class' => 'yii\\swiftmailer\\Mailer', 'useFileTransport' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'db' => require __DIR__ . '/db.php', 'urlManager' => ['enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => ['<_c:[\\w\\-]+>/<id:\\d+>' => '<_c>/view', '<_c:[\\w\\-]+>' => '<_c>/index', '<_c:[\\w\\-]+>/<_a:[\\w\\-]+>/<id:\\d+>' => '<_c>/<_a>']]], 'params' => $params];
if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = ['class' => 'yii\\debug\\Module'];
    $config['bootstrap'][] = 'gii';
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = ['class' => \yii\gii\Module::className()];
}
return $config;
Exemplo n.º 6
0
<?php

/**
 * Created by PhpStorm.
 * User: bug
 * Date: 22.06.15
 * Time: 18:48
 */
$config = ['components' => ['request' => ['cookieValidationKey' => 'tZ_RrBX7OvzjL1mHW1d0zE5XeI-O3RkX']]];
if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = ['class' => \yii\debug\Module::className(), 'allowedIPs' => ['*']];
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = ['class' => \yii\gii\Module::className(), 'allowedIPs' => ['*']];
}
return $config;
Exemplo n.º 7
0
 /**
  * Bootstrap method to be called during application bootstrap stage.
  * @param Application $app the application currently running
  */
 public function bootstrap($app)
 {
     /** @var Module $module */
     if (($module = $app->getModule('admin')) == null || !$module instanceof Module) {
         return;
     }
     $class = 'nullref\\admin\\models\\Admin';
     $definition = $module->adminModel;
     if ($module->enableRbac) {
         $module->setComponents(['authManager' => $module->authManager, 'roleContainer' => $module->roleContainer]);
     }
     Yii::$container->set($class, $definition);
     $className = is_array($definition) ? $definition['class'] : $definition;
     Event::on(AdminQuery::className(), AdminQuery::EVENT_INIT, function (Event $e) use($class, $className) {
         if ($e->sender->modelClass == $class) {
             $e->sender->modelClass = $className;
         }
     });
     /** I18n */
     if (!isset($app->get('i18n')->translations['admin*'])) {
         $app->i18n->translations['admin*'] = ['class' => PhpMessageSource::className(), 'basePath' => '@nullref/admin/messages'];
     }
     if ($app instanceof WebApplication) {
         Yii::$app->setComponents(['admin' => ['class' => 'nullref\\admin\\components\\User', 'identityClass' => $className, 'loginUrl' => ['admin/login']]]);
         $app->urlManager->addRules(['/admin/login' => '/admin/main/login']);
         $app->urlManager->addRules(['/admin/logout' => '/admin/main/logout']);
         Event::on(BaseModule::className(), BaseModule::EVENT_BEFORE_ACTION, function () use($module) {
             if (Yii::$app->controller instanceof IAdminController) {
                 /** @var Controller $controller */
                 $controller = Yii::$app->controller;
                 $controller->layout = $module->layout;
                 if ($controller->module != $module) {
                     $controller->module->setLayoutPath($module->getLayoutPath());
                 }
                 if (!isset($controller->behaviors()['access'])) {
                     $controller->attachBehavior('access', AccessControl::className());
                 }
                 Yii::$app->errorHandler->errorAction = $module->errorAction;
             }
         });
     } elseif ($app instanceof ConsoleApplication) {
         if ($module !== null) {
             /** @var Module $module */
             if ($module->enableRbac) {
                 $module->controllerMap['rbac'] = ['class' => 'nullref\\admin\\console\\RbacController'];
             }
         }
     }
     Event::on(Module::className(), Module::EVENT_BEFORE_INIT, function (Event $event) use($app) {
         $module = $event->sender;
         /** @var Module $module */
         if ($module->enableRbac) {
             if ($app instanceof ConsoleApplication) {
                 $module->controllerMap['rbac'] = ['class' => 'nullref\\admin\\console\\RbacController'];
             }
             $module->setComponents(['authManager' => $module->authManager, 'roleContainer' => $module->roleContainer]);
         }
     });
     if (YII_ENV_DEV && class_exists('yii\\gii\\Module')) {
         Event::on(Gii::className(), Gii::EVENT_BEFORE_ACTION, function (Event $event) {
             /** @var Gii $gii */
             $gii = $event->sender;
             $gii->generators['crud'] = ['class' => 'yii\\gii\\generators\\crud\\Generator', 'templates' => ['admin-crud' => '@nullref/admin/generators/crud/admin']];
             $gii->generators['stuff'] = ['class' => 'nullref\\admin\\generators\\stuff\\Generator', 'templates' => ['default' => '@nullref/admin/generators/stuff/default']];
         });
     }
 }