/** * Declares the name of the database table associated with this AR class. * By default this method returns the class name as the table name by calling [[Inflector::camel2id()]] * with prefix [[Connection::tablePrefix]]. For example if [[Connection::tablePrefix]] is 'tbl_', * 'Customer' becomes 'tbl_customer', and 'OrderItem' becomes 'tbl_order_item'. You may override this method * if the table is not named after this convention. * @return string the table name */ public static function tableName() { return '{{%' . Inflector::camel2id(StringHelper::basename(get_called_class()), '_') . '}}'; }
/** * 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; }