Ejemplo n.º 1
0
 public function bootstrap($app)
 {
     /** @var Module $module */
     if ($app->hasModule('blog') && ($module = $app->getModule('blog')) instanceof Module) {
         $classMap = array_merge($this->classMap, $module->classMap);
         Yii::$container->setSingleton(BlogStatusList::className(), $classMap['BlogStatusList']);
         foreach (['PostSearch', 'PostQuery', 'Post'] as $item) {
             $className = '\\nullref\\blog\\models\\' . $item;
             $postClass = $className::className();
             $definition = $classMap[$item];
             Yii::$container->set($postClass, $definition);
         }
     }
     if ($app instanceof WebApplication) {
         if (!isset($app->i18n->translations['blog*'])) {
             $app->i18n->translations['blog*'] = ['class' => PhpMessageSource::className(), 'basePath' => '@nullref/blog/messages'];
         }
         $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => $module->urlRules];
         $app->urlManager->addRules([new GroupUrlRule($configUrlRule)], false);
     }
 }
Ejemplo n.º 2
0
 /**
  * @return string
  * @throws \yii\base\InvalidConfigException
  */
 public function getStatusTitle()
 {
     $list = Yii::$container->get(BlogStatusList::className())->getList();
     return isset($list[$this->status]) ? $list[$this->status] : Yii::t('blog', 'N/A');
 }