本文整理汇总了PHP中yii\base\Module::getModule方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::getModule方法的具体用法?PHP Module::getModule怎么用?PHP Module::getModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\base\Module
的用法示例。
在下文中一共展示了Module::getModule方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRouteRecrusive
/**
*
* @param \yii\base\Module $module
* @param array $result
*/
private static function getRouteRecrusive($module, &$result)
{
foreach ($module->getModules() as $id => $child) {
if (($child = $module->getModule($id)) !== null) {
self::getRouteRecrusive($child, $result);
}
}
/* @var $controller \yii\base\Controller */
foreach ($module->controllerMap as $id => $value) {
$controller = Yii::createObject($value, [$id, $module]);
self::getActionRoutes($controller, $result);
$result[] = '/' . $controller->uniqueId . '/*';
}
$namespace = trim($module->controllerNamespace, '\\') . '\\';
self::getControllerRoutes($module, $namespace, '', $result);
$result[] = ($module->uniqueId === '' ? '' : '/' . $module->uniqueId) . '/*';
}
示例2: getModuleCommands
/**
* Returns available commands of a specified module.
* @param \yii\base\Module $module the module instance
* @return array the available command names
*/
protected function getModuleCommands($module)
{
$prefix = $module instanceof Application ? '' : $module->getUniqueId() . '/';
$commands = [];
foreach (array_keys($module->controllerMap) as $id) {
$commands[] = $prefix . $id;
}
foreach ($module->getModules() as $id => $child) {
if (($child = $module->getModule($id)) === null) {
continue;
}
foreach ($this->getModuleCommands($child) as $command) {
$commands[] = $command;
}
}
$controllerPath = $module->getControllerPath();
if (is_dir($controllerPath)) {
$files = scandir($controllerPath);
foreach ($files as $file) {
if (!empty($file) && substr_compare($file, 'Controller.php', -14, 14) === 0) {
$controllerClass = $module->controllerNamespace . '\\' . substr(basename($file), 0, -4);
if ($this->validateControllerClass($controllerClass)) {
$commands[] = $prefix . Inflector::camel2id(substr(basename($file), 0, -14));
}
}
}
}
return $commands;
}
示例3: getModuleCommands
/**
* Returns available commands of a specified module.
* @param \yii\base\Module $module the module instance
* @return array the available command names
*/
protected function getModuleCommands($module)
{
$prefix = $module instanceof Application ? '' : $module->getUniqueID() . '/';
$commands = [];
foreach (array_keys($module->controllerMap) as $id) {
$commands[] = $prefix . $id;
}
foreach ($module->getModules() as $id => $child) {
if (($child = $module->getModule($id)) === null) {
continue;
}
foreach ($this->getModuleCommands($child) as $command) {
$commands[] = $command;
}
}
$controllerPath = $module->getControllerPath();
if (is_dir($controllerPath)) {
$files = scandir($controllerPath);
foreach ($files as $file) {
if (strcmp(substr($file, -14), 'Controller.php') === 0) {
$commands[] = $prefix . Inflector::camel2id(substr(basename($file), 0, -14));
}
}
}
return $commands;
}
示例4: getRouteRecrusive
/**
*
* @param \yii\base\Module $module
* @param array $result
*/
private static function getRouteRecrusive($module, &$result, $exclude)
{
foreach ($module->getModules() as $id => $child) {
if (($child = $module->getModule($id)) !== null) {
if (!in_array($child->id, $exclude['module'])) {
self::getRouteRecrusive($child, $result, $exclude);
}
}
}
/* @var $controller \yii\base\Controller */
foreach ($module->controllerMap as $id => $value) {
$controller = Yii::createObject($value, [$id, $module]);
if (!in_array($controller->module->id, $exclude['module']) && !in_array($controller->id, $exclude['controller'])) {
self::getActionRoutes($controller, $result);
//$result[$controller->module->id][$controller->id][] = '*';
//$result['map'][$controller->module->id]['*'][] = '*';
/*
$result['map'][] = [
'module' => $controller->module->id,
'controller' => $controller->id,
'action' => '*',
];
//*/
}
}
if (!in_array($module->id, $exclude['module'])) {
$namespace = trim($module->controllerNamespace, '\\') . '\\';
self::getControllerRoutes($module, $namespace, '', $result, $exclude);
//$result[$module->id]['*'] = '*';
//$result['map'][$controller->module->id]['*'][] = '*';
/*
$result['model'][] = [
'module' => $module->id,
'controller' => '*',
'action' => '*',
];
//*/
}
}