本文整理汇总了PHP中yii\base\Application::hasModule方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::hasModule方法的具体用法?PHP Application::hasModule怎么用?PHP Application::hasModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\base\Application
的用法示例。
在下文中一共展示了Application::hasModule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bootstrap
/**
* @param \yii\base\Application $app
* @throws ModuleBootstrapException
* @throws ModuleUndefinedClassException
*/
public function bootstrap($app)
{
$this->app = $app;
$modules = array_diff(scandir($this->getModulesPath()), array('..', '.'));
$modulesOrder = [];
foreach ($modules as $module) {
$className = 'modules\\' . $module . '\\Module';
if (!class_exists($className)) {
throw new ModuleUndefinedClassException('Can\'t load module ' . $className);
}
$interfaces = class_implements($className);
// since PHP 5.5
// if (!isset($interfaces[ModuleBootstrapInterface::class])) {
if (!isset($interfaces['common\\interfaces\\ModuleBootstrapInterface'])) {
throw new ModuleBootstrapException('Module ' . $className . ' must implement common\\ModuleBootstrapInterface interface');
}
if (!$app->hasModule($module)) {
$app->setModule($module, $className);
}
// configure some properties
$config = $this->getConfig($module);
$this->configure($config);
$modulesOrder[$className] = isset($config['bootOrder']) ? (int) $config['bootOrder'] : self::BOOT_ORDER_DEFAULT;
}
asort($modulesOrder);
foreach ($modulesOrder as $className => $order) {
$className::bootstrap($app);
}
}
示例2: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
/** @var Module $module */
/** @var \yii\db\ActiveRecord $modelName */
if ($app->hasModule('activeuser') && ($module = $app->getModule('activeuser')) instanceof Module) {
$this->_modelMap = array_merge($this->_modelMap, $module->modelMap);
foreach ($this->_modelMap as $name => $definition) {
$class = "inblank\\activeuser\\models\\" . $name;
Yii::$container->set($class, $definition);
$modelName = is_array($definition) ? $definition['class'] : $definition;
$module->modelMap[$name] = $modelName;
}
if ($app instanceof ConsoleApplication) {
$app->controllerMap['activeuser'] = ['class' => 'inblank\\activeuser\\commands\\DefaultController'];
} else {
// init user
Yii::$container->set('yii\\web\\User', ['loginUrl' => ['/activeuser/account/login'], 'identityClass' => self::di('User')]);
$configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => defined('IS_BACKEND') ? $module->urlRulesBackend : $module->urlRulesFrontend];
if ($module->urlPrefix != 'activeuser') {
$configUrlRule['routePrefix'] = 'activeuser';
}
$app->urlManager->addRules([new GroupUrlRule($configUrlRule)], false);
if (defined('IS_BACKEND')) {
// is backend, and controller have other namespace
$module->controllerNamespace = 'inblank\\activeuser\\controllers\\backend';
$module->frontendUrlManager = new yii\web\UrlManager(['baseUrl' => '/', 'enablePrettyUrl' => true, 'showScriptName' => false]);
$configUrlRule['rules'] = $module->urlRulesFrontend;
$module->frontendUrlManager->addRules([new GroupUrlRule($configUrlRule)], false);
}
}
if (!isset($app->get('i18n')->translations['activeuser*'])) {
$app->get('i18n')->translations['activeuser*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages'];
}
}
}
示例3: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
if (!isset($app->getModule('gii')->generators['ajaxcrud'])) {
$app->getModule('gii')->generators['ajaxcrud'] = 'johnitvn\\ajaxcrud\\generators\\Generator';
}
}
}
示例4: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
if (!isset($app->getModule('gii')->generators['fixture-generator'])) {
$app->getModule('gii')->generators['fixture-generator'] = ['class' => __NAMESPACE__ . '\\FixtureGenerator'];
}
}
}
示例5: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
if ($app instanceof \yii\console\Application) {
$app->controllerMap['gii-batch'] = 'cornernote\\gii\\commands\\BatchController';
}
}
}
示例6: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
if (!isset($app->getModule('gii')->generators['enhanced-gii'])) {
$app->getModule('gii')->generators['enhanced-gii-model'] = 'mootensai\\enhancedgii\\model\\Generator';
$app->getModule('gii')->generators['enhanced-gii-crud'] = 'mootensai\\enhancedgii\\crud\\Generator';
}
}
}
示例7: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
/**@var Module $gii */
if ($app->hasModule('gii') && ($gii = $app->getModule('gii'))) {
if (!isset($gii->generators['migration'])) {
$gii->generators['migration'] = 'navatech\\migration\\gii\\Generator';
}
}
}
示例8: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
Yii::setAlias("@ajaxcrud", __DIR__);
Yii::setAlias("@johnitvn/ajaxcrud", __DIR__);
if ($app->hasModule('gii')) {
if (!isset($app->getModule('gii')->generators['ajaxcrud'])) {
$app->getModule('gii')->generators['ajaxcrud'] = 'johnitvn\\ajaxcrud\\generators\\Generator';
}
}
}
示例9: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
$app->getModule('gii')->generators['giiant-model'] = 'pafnow\\giiant\\model\\Generator';
$app->getModule('gii')->generators['giiant-crud'] = 'pafnow\\giiant\\crud\\Generator';
if ($app instanceof \yii\console\Application) {
$app->controllerMap['giiant-batch'] = 'pafnow\\giiant\\commands\\BatchController';
}
}
}
示例10: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
if (!isset($app->getModule('gii')->generators['giiant-crud']['templates']['twig'])) {
$app->getModule('gii')->generators['giiant-crud'] = ['class' => 'schmunk42\\giiant\\crud\\Generator', 'templates' => ['twig' => '@vendor/esquire900/yii2-giiant-twig/crud']];
}
if ($app instanceof \yii\console\Application) {
$app->controllerMap['giiant-twig'] = 'esquire900\\giianttwig\\commands\\ConvertController';
}
}
}
示例11: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
if (!isset($app->getModule('gii')->generators['giix-model'])) {
$app->getModule('gii')->generators['giix-model'] = 'veyselsahin\\giix\\model\\Generator';
}
if (!isset($app->getModule('gii')->generators['giix-crud'])) {
$app->getModule('gii')->generators['giix-crud'] = 'veyselsahin\\giix\\crud\\Generator';
}
if ($app instanceof \yii\console\Application) {
$app->controllerMap['giix-batch'] = 'veyselsahin\\giix\\commands\\BatchController';
}
}
}
示例12: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
// \Yii::setAlias('@mtengii','@vendor/mootensai/yii2-enhanced-gii');
if ($app->hasModule('gii')) {
if (!isset($app->getModule('gii')->generators['enhanced-gii'])) {
$app->getModule('gii')->generators['enhanced-gii-model'] = 'mootensai\\enhancedgii\\model\\Generator';
$app->getModule('gii')->generators['enhanced-gii-crud']['class'] = 'mootensai\\enhancedgii\\crud\\Generator';
// $app->getModule('gii')->generators['enhanced-gii-crud']['templates'] = [
// 'default' => '@mtengii/crud/default',
// 'nested' => '@mtengii/crud/nested'
// ];
$app->getModule('gii')->generators['enhanced-gii-migration'] = 'mootensai\\enhancedgii\\migration\\Generator';
}
}
}
示例13: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
if (!isset($app->getModule('gii')->generators['giiant-model'])) {
$app->getModule('gii')->generators['giiant-model'] = 'schmunk42\\giiant\\generators\\model\\Generator';
}
if (!isset($app->getModule('gii')->generators['giiant-crud'])) {
$app->getModule('gii')->generators['giiant-crud'] = 'schmunk42\\giiant\\generators\\crud\\Generator';
}
if (!isset($app->getModule('gii')->generators['giiant-module'])) {
$app->getModule('gii')->generators['giiant-module'] = 'schmunk42\\giiant\\generators\\module\\Generator';
}
if (!isset($app->getModule('gii')->generators['giiant-test'])) {
$app->getModule('gii')->generators['giiant-test'] = 'schmunk42\\giiant\\generators\\test\\Generator';
}
if ($app instanceof \yii\console\Application) {
$app->controllerMap['giiant-batch'] = 'schmunk42\\giiant\\commands\\BatchController';
}
}
}
示例14: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
if (!isset($app->getModule('gii')->generators['giiant-model'])) {
$app->getModule('gii')->generators['giiant-model'] = 'schmunk42\\giiant\\generators\\model\\Generator';
}
if (!isset($app->getModule('gii')->generators['giiant-extension'])) {
$app->getModule('gii')->generators['giiant-extension'] = 'schmunk42\\giiant\\generators\\extension\\Generator';
}
if (!isset($app->getModule('gii')->generators['giiant-crud'])) {
$app->getModule('gii')->generators['giiant-crud'] = ['class' => 'schmunk42\\giiant\\generators\\crud\\Generator', 'templates' => ['editable' => __DIR__ . '/generators/crud/editable']];
}
if (!isset($app->getModule('gii')->generators['giiant-module'])) {
$app->getModule('gii')->generators['giiant-module'] = 'schmunk42\\giiant\\generators\\module\\Generator';
}
if (!isset($app->getModule('gii')->generators['giiant-test'])) {
$app->getModule('gii')->generators['giiant-test'] = 'schmunk42\\giiant\\generators\\test\\Generator';
}
if ($app instanceof \yii\console\Application) {
$app->controllerMap['giiant-batch'] = 'schmunk42\\giiant\\commands\\BatchController';
}
}
}
示例15: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
$app->getModule('gii')->generators['magicscopes'] = 'phpshko\\magicscopes\\gii\\model\\Generator';
}
}