本文整理匯總了PHP中yii\base\Module::getControllerPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP Module::getControllerPath方法的具體用法?PHP Module::getControllerPath怎麽用?PHP Module::getControllerPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yii\base\Module
的用法示例。
在下文中一共展示了Module::getControllerPath方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getModuleControllers
/**
* @param Module $module
*
* @return array
*/
public function getModuleControllers(Module $module)
{
$controllers = [];
$path = $module->getControllerPath();
$files = array_diff(scandir($path), ['..', '.']);
asort($files);
foreach ($files as $file) {
if (strcmp(mb_substr($file, -mb_strlen(self::CONTROLLER_FILE)), self::CONTROLLER_FILE) === 0) {
$id = Inflector::camel2id(mb_substr(basename($file), 0, -mb_strlen(self::CONTROLLER_FILE)));
$controller = $this->getModuleController($module, $id);
if ($controller) {
$controllers[$id] = $this->getControllerActions($controller);
}
}
}
return $controllers;
}
示例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;
}