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.
		
		
		
		
		
			
		
			
				
					
					
						
							77 lines
						
					
					
						
							2.0 KiB
						
					
					
				
			
		
		
	
	
							77 lines
						
					
					
						
							2.0 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, title as content, CONCAT('/banners/manage/banner/view/', id) AS url FROM {{banners}}"; | 
						|
 | 
						|
		$app->getUrlManager()->addRules([ | 
						|
			'banner/view' => 'banners/banner/view', | 
						|
			'banner/click' => 'banners/banner/click', | 
						|
		]); | 
						|
 | 
						|
		$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', | 
						|
			], | 
						|
		]); | 
						|
 | 
						|
		// add menu items | 
						|
		if (basename(\Yii::$app->getBasePath()) === 'backend') { | 
						|
			$app->params['adminMenu'][] = [ | 
						|
				'label'   => \Yii::t( 'banners', 'Banners' ), | 
						|
				'icon'    => 'flag', | 
						|
				'items'   => [ | 
						|
					[ | 
						|
						'label'  => \Yii::t( 'banners', 'Banners' ), | 
						|
						'icon'   => 'caret-right', | 
						|
						'url'    => [ '/banners/manage/banner/index' ], | 
						|
						//'active' => \Yii::$app->controller->getUniqueId() == 'banners/manage/banner' | 
						|
					], | 
						|
					[ | 
						|
						'label'  => \Yii::t( 'banners', 'Places' ), | 
						|
						'icon'   => 'caret-right', | 
						|
						'url'    => [ '/banners/manage/place/index' ], | 
						|
						//'active' => \Yii::$app->controller->getUniqueId() == 'banners/manage/place' | 
						|
					], | 
						|
				], | 
						|
				'visible' => $app->user->can( 'admin' ) || \Yii::$app->user->can( 'BannersManagement' ), | 
						|
			]; | 
						|
		} | 
						|
	} | 
						|
}
 | 
						|
 |