You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

63 lines
1.6 KiB

<?php
namespace common\modules\banners;
use core\components\modules\ModuleInterface;
use yii\helpers\ArrayHelper;
/**
* blog module definition class
*/
class BannersModule extends \yii\base\Module implements ModuleInterface
{
/**
* @inheritdoc
*/
public $controllerNamespace = 'common\modules\banners\controllers';
/**
* @inheritdoc
*/
public function init()
{
parent::init();
// custom initialization code goes here
}
public function bootstrap($app)
{
// add migration path
$app->controllerMap['migrate']['migrationPath'][] = '@common/modules/banners/migrations';
// add search rules
$app->params['search_rules'][] = "SELECT title, CONCAT('/banners/manage/banner/view/', id) AS url FROM {{banners}}";
$app->getUrlManager()->addRules([
'banners/manage/banner/view/<id:\d+>' => 'banners/manage/banner/view',
]);
// add languages
$app->getI18n()->translations = ArrayHelper::merge($app->getI18n()->translations, [
'banners' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@common/modules/banners/messages',
],
'banners_public' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@common/modules/banners/messages',
],
]);
// add menu items
if (basename($app->getBasePath()) === 'backend') {
$app->params['adminMenu'][] = [
'label' => \Yii::t( 'banners', 'Banners' ),
'icon' => 'flag',
'url' => [ '/banners/manage/banner/index' ],
'visible' => \Yii::$app->user->can( 'admin' ) || \Yii::$app->user->can( 'BannersManagement' )
];
}
}
}