public function getThumbnailTrue() { if ($this->image) { $name = \yii\helpers\StringHelper::basename($this->image); $dir = \yii\helpers\StringHelper::dirname($this->image); return Yii::getAlias($dir . '/thumb/' . $name); } }
public function actionIndex() { // --------------------------- TITLE ----------------------------------- $this->getView()->title .= ' :: ' . S::upperCamelize($this->action->id); // TODO // debug info ---------------------------------------------------------- AppDebug::dump(['method' => __METHOD__, 'line' => __LINE__, 'module' => $this->module->id, 'controller' => $this->id, 'action' => $this->action->id, 'dirname' => StringHelper::dirname(Yii::getAlias('@frontend')), 'version' => Yii::getVersion(), 'clientIp' => $this->getClientIp(), 'userIp' => $this->getRequest()->userIP, 'language' => Yii::$app->language, 'user' => Yii::$app->getUser(), 'isGuest' => Yii::$app->getUser()->isGuest, 'view params' => $this->getView()->params]); // --------------------------------------------------------------------- return $this->render('index'); }
/** * walk througt all modules gii directories and collect Giant crud generator saved forms. * * @return array */ public static function loadSavedForms($generatorName) { $suffix = str_replace(' ', '', $generatorName); if (self::$savedFormList) { return self::$savedFormList; } /* * get all possible gii directories with out validation on existing */ $giiDirs = []; $giiDirs[] = \Yii::getAlias('@app/gii'); if ($commonGiiDir = \Yii::getAlias('@common/gii', false)) { $giiDirs[] = $commonGiiDir; } foreach (\Yii::$app->modules as $moduleId => $module) { /* * get module base path */ if (method_exists($module, 'getBasePath')) { $basePath = $module->getBasePath(); } else { $reflector = new \ReflectionClass($module['class']); $basePath = StringHelper::dirname($reflector->getFileName()); } $basePath .= '/gii'; $giiDirs[] = $basePath; } /* * from all gii directories collec forms */ $forms = []; foreach ($giiDirs as $basePath) { /* * search in module gii directory all forms json files * with required suffix */ if (!file_exists($basePath)) { continue; } $files = scandir($basePath); foreach ($files as $file) { if (!preg_match('#' . $suffix . '\\.json$#', $file)) { continue; } $name = preg_replace('#' . $suffix . '\\.json$#', '', $file); $forms[$moduleId . $name] = ['jsonData' => file_get_contents($basePath . '/' . $file), 'label' => $moduleId . ' - ' . $name]; } } return self::$savedFormList = $forms; }
/** * * @param string $url * @return self */ protected static function setDomains($url) { self::$baseFolder = ''; if (empty(self::$homeUrl)) { self::$homeUrl = rtrim(StringHelper::dirname($_SERVER['PHP_SELF']), '/'); } if (empty(self::$baseFolder)) { if ($str = mb_stristr(self::$homeUrl, 'admin', TRUE)) { self::$baseFolder = $str . "admin"; } if ($str == false && !empty(self::$homeUrl)) { self::$baseFolder = rtrim(self::$homeUrl, '/'); } self::$baseFolder = rtrim(self::$baseFolder, '/'); } $url = StringHelper::byteSubstr($url, StringHelper::byteLength(self::$baseFolder), StringHelper::byteLength($url)); self::$domains = explode('/', ltrim($url, '/')); return self::$domains; }
public function getThumbnailTrue() { $image = $this->avatar; $pos = strpos($image, "http"); if ($pos !== FALSE) { return $this->avatar; } else { if ($image) { $name = \yii\helpers\StringHelper::basename($image); $dir = \yii\helpers\StringHelper::dirname($image); return Yii::getAlias($dir . '/thumb/' . $name); } else { return Yii::$app->request->baseUrl . '/img/photo.jpg.png'; } } }
$searchModelAlias = $searchModelClass . 'Search'; } /* @var $class ActiveRecordInterface */ $class = $generator->modelClass; $pks = $class::primaryKey(); $urlParams = $generator->generateUrlParams(); $actionParams = $generator->generateActionParams(); $actionParamComments = $generator->generateActionParamComments(); $temporal=new $class(); echo "<?php\n"; ?> namespace <?= StringHelper::dirname(ltrim($generator->controllerClass, '\\')) ?>; use Yii; use <?= ltrim($generator->modelClass, '\\') ?>; <?php if (!empty($generator->searchModelClass)): ?> use <?= ltrim($generator->searchModelClass, '\\') . (isset($searchModelAlias) ? " as $searchModelAlias" : "") ?>; <?php else: ?> use yii\data\ActiveDataProvider; <?php endif; ?> use <?= ltrim($generator->baseControllerClass, '\\') ?>; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; <?php if ( is_a($temporal, 'app\models\TramitExt') ): ?> use app\models\USUARIOS; use app\models\PasosTramite;
$searchModelClass = StringHelper::basename($generator->searchModelClass); if ($modelClass === $searchModelClass) { $searchModelAlias = $searchModelClass . 'Search'; } /* @var $class ActiveRecordInterface */ $class = $generator->modelClass; $pks = $class::primaryKey(); $urlParams = $generator->generateUrlParams(); $actionParams = $generator->generateActionParams(); $actionParamComments = $generator->generateActionParamComments(); $tableSchema = $generator->getTableSchema(); echo "<?php\n"; ?> namespace <?php echo StringHelper::dirname(ltrim($generator->controllerClass, '\\')); ?> ; use Yii; use pavlinter\adm\Adm; use <?php echo ltrim($generator->modelClass, '\\'); ?> ; <?php if (!empty($generator->searchModelClass)) { ?> use <?php echo ltrim($generator->searchModelClass, '\\') . (isset($searchModelAlias) ? " as {$searchModelAlias}" : ""); ?>
$modelClass = StringHelper::basename($generator->modelClass); $searchModelClass = StringHelper::basename($generator->searchModelClass); if ($modelClass === $searchModelClass) { $searchModelAlias = $searchModelClass . 'Search'; } /* @var $class ActiveRecordInterface */ $class = $generator->modelClass; $pks = $class::primaryKey(); $urlParams = $generator->generateUrlParams(); $actionParams = $generator->generateActionParams(); $actionParamComments = $generator->generateActionParamComments(); echo "<?php\n"; ?> namespace <?php echo StringHelper::dirname(ltrim($generator->getControllerClass(), '\\')); ?> ; use Yii; use <?php echo ltrim($generator->modelClass, '\\'); ?> ; <?php if (!empty($generator->searchModelClass)) { ?> use <?php echo ltrim($generator->searchModelClass, '\\') . (isset($searchModelAlias) ? " as {$searchModelAlias}" : ""); ?> ;
public function generate() { if ($this->singularEntities) { $this->modelClass = Inflector::singularize($this->modelClass); $this->controllerClass = Inflector::singularize(substr($this->controllerClass, 0, strlen($this->controllerClass) - 10)) . 'Controller'; $this->searchModelClass = Inflector::singularize($this->searchModelClass); } $controllerFile = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->controllerClass, '\\')) . '.php'); $baseControllerFile = StringHelper::dirname($controllerFile) . '/base/' . StringHelper::basename($controllerFile); $restControllerFile = StringHelper::dirname($controllerFile) . '/api/' . StringHelper::basename($controllerFile); $files[] = new CodeFile($baseControllerFile, $this->render('controller.php')); $params['controllerClassName'] = \yii\helpers\StringHelper::basename($this->controllerClass); if ($this->overwriteControllerClass || !is_file($controllerFile)) { $files[] = new CodeFile($controllerFile, $this->render('controller-extended.php', $params)); } if ($this->overwriteRestControllerClass || !is_file($restControllerFile)) { $files[] = new CodeFile($restControllerFile, $this->render('controller-rest.php', $params)); } if (!empty($this->searchModelClass)) { $searchModel = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->searchModelClass, '\\') . '.php')); $files[] = new CodeFile($searchModel, $this->render('search.php')); } $viewPath = $this->getViewPath(); $templatePath = $this->getTemplatePath() . '/views'; foreach (scandir($templatePath) as $file) { if (empty($this->searchModelClass) && $file === '_search.php') { continue; } if (is_file($templatePath . '/' . $file) && pathinfo($file, PATHINFO_EXTENSION) === 'php') { $files[] = new CodeFile("{$viewPath}/{$file}", $this->render("views/{$file}")); } } return $files; }
/* @var $this yii\web\View */ /* @var $generator \infinitydevphp\gii\crud\Generator */ $modelClass = StringHelper::basename(ltrim(str_replace('/', '\\', $generator->reallySearchNs), '\\')); $searchModelClass = StringHelper::basename($generator->reallySearchNs); if ($modelClass === $searchModelClass) { $modelAlias = $modelClass . 'Model'; } $rules = $generator->generateSearchRules(); $labels = $generator->generateSearchLabels(); $searchAttributes = $generator->getSearchAttributes(); $searchConditions = $generator->generateSearchConditions(); echo "<?php\n"; ?> namespace <?php echo StringHelper::dirname(str_replace('/', '\\', ltrim($generator->reallySearchNs, '\\'))); ?> ; use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; use <?php echo ltrim($generator->modelClass, '\\') . (isset($modelAlias) ? " as {$modelAlias}" : ""); ?> ; /** * <?php echo $searchModelClass; ?>
public function generate() { $accessDefinitions = (require $this->getTemplatePath() . '/access_definition.php'); $this->controllerNs = \yii\helpers\StringHelper::dirname(ltrim($this->controllerClass, '\\')); $this->moduleNs = \yii\helpers\StringHelper::dirname(ltrim($this->controllerNs, '\\')); $controllerName = substr(\yii\helpers\StringHelper::basename($this->controllerClass), 0, -10); if ($this->singularEntities) { $this->modelClass = Inflector::singularize($this->modelClass); $this->controllerClass = Inflector::singularize(substr($this->controllerClass, 0, strlen($this->controllerClass) - 10)) . 'Controller'; $this->searchModelClass = Inflector::singularize($this->searchModelClass); } $controllerFile = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->controllerClass, '\\')) . '.php'); $baseControllerFile = StringHelper::dirname($controllerFile) . '/base/' . StringHelper::basename($controllerFile); $restControllerFile = StringHelper::dirname($controllerFile) . '/api/' . StringHelper::basename($controllerFile); /* * search generated migration and overwrite it or create new */ $migrationDir = StringHelper::dirname(StringHelper::dirname($controllerFile)) . '/migrations'; if (file_exists($migrationDir) && ($migrationDirFiles = glob($migrationDir . '/m*_' . $controllerName . '00_access.php'))) { $this->migrationClass = pathinfo($migrationDirFiles[0], PATHINFO_FILENAME); } else { $this->migrationClass = 'm' . date('ymd_Hi') . '00_' . $controllerName . '_access'; } $files[] = new CodeFile($baseControllerFile, $this->render('controller.php', ['accessDefinitions' => $accessDefinitions])); $params['controllerClassName'] = \yii\helpers\StringHelper::basename($this->controllerClass); if ($this->overwriteControllerClass || !is_file($controllerFile)) { $files[] = new CodeFile($controllerFile, $this->render('controller-extended.php', $params)); } if ($this->overwriteRestControllerClass || !is_file($restControllerFile)) { $files[] = new CodeFile($restControllerFile, $this->render('controller-rest.php', $params)); } if (!empty($this->searchModelClass)) { $searchModel = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->searchModelClass, '\\') . '.php')); if ($this->overwriteSearchModelClass || !is_file($searchModel)) { $files[] = new CodeFile($searchModel, $this->render('search.php')); } } $viewPath = $this->getViewPath(); $templatePath = $this->getTemplatePath() . '/views'; foreach (scandir($templatePath) as $file) { if (empty($this->searchModelClass) && $file === '_search.php') { continue; } if (is_file($templatePath . '/' . $file) && pathinfo($file, PATHINFO_EXTENSION) === 'php') { echo $file; $files[] = new CodeFile("{$viewPath}/{$file}", $this->render("views/{$file}", ['permisions' => $permisions])); } } if ($this->generateAccessFilterMigrations) { /* * access migration */ $migrationFile = $migrationDir . '/' . $this->migrationClass . '.php'; //var_dump($migrationFile);exit; $files[] = new CodeFile($migrationFile, $this->render('migration_access.php', ['accessDefinitions' => $accessDefinitions])); /* * access roles translation */ $forRoleTranslationFile = StringHelper::dirname(StringHelper::dirname($controllerFile)) . '/messages/for-translation/' . $controllerName . '.php'; $files[] = new CodeFile($forRoleTranslationFile, $this->render('roles-translation.php', ['accessDefinitions' => $accessDefinitions])); } /* * create gii/[name]GiantCRUD.json with actual form data */ $suffix = str_replace(' ', '', $this->getName()); $controllerFileinfo = pathinfo($controllerFile); $formDataFile = StringHelper::dirname(StringHelper::dirname($controllerFile)) . '/gii/' . str_replace('Controller', $suffix, $controllerFileinfo['filename']) . '.json'; //$formData = json_encode($this->getFormAttributesValues()); $formData = json_encode(SaveForm::getFormAttributesValues($this, $this->formAttributes())); $files[] = new CodeFile($formDataFile, $formData); return $files; }
/** * @return string The namespace for the child class which is used by the * developers for non-automatically generated code. */ public function getChildNs() { return StringHelper::dirname($this->ns); }
/** * Returns the migrations that are not applied. * * @return array List of new migrations (key: migration version; value: alias) */ protected function getNewMigrations() { $applied = []; foreach ($this->getMigrationHistory(null) as $version => $info) { $applied[substr($version, 1, 13)] = true; } $moduleMigrations = FileHelper::findFiles(Yii::getAlias($this->modulesPath), ['only' => ['*/migrations/*php']]); array_walk($moduleMigrations, function (&$value) { $value = dirname($value); }); $moduleMigrations = array_unique($moduleMigrations); $directories = ArrayHelper::merge([$this->migrationPath], $moduleMigrations, $this->migrationLookup); array_walk($directories, function (&$directory) { $appPath = Yii::getAlias('@app'); // For correct detection on Windows $vendorPath = StringHelper::dirname($appPath) . DIRECTORY_SEPARATOR . 'vendor'; $directory = str_replace($appPath, '@app', $directory); $directory = str_replace($vendorPath, '@vendor', $directory); $directory = FileHelper::normalizePath($directory, '/'); }); $migrations = []; foreach ($directories as $alias) { $dir = Yii::getAlias($alias); $handle = opendir($dir); while (($file = readdir($handle)) !== false) { if ($file === '.' || $file === '..') { continue; } $path = "{$dir}/{$file}"; if (preg_match('/^(m(\\d{6}_\\d{6})_.*?)\\.php$/', $file, $matches) && is_file($path) && !isset($applied[$matches[2]])) { $migrations[$matches[1]] = $alias; } } closedir($handle); } ksort($migrations); return $migrations; }
/** * 生成搜索模型代码文件 * * @return CodeFile * @throws \yii\base\InvalidConfigException */ protected function generateSearchModelCodeFile() { $currentFormModelFullClass = StringHelper::dirname($this->searchModelClass) . '\\' . StringHelper::basename($this->modelClass); $isFormDirExistModel = class_exists($currentFormModelFullClass); $searchModel = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->searchModelClass, '\\') . '.php')); return new CodeFile($searchModel, $this->render('search.php', ['isFormDirExistModel' => $isFormDirExistModel])); }
public function getNameSpace() { $class = $this->modelClass; return StringHelper::dirname($class); }
$modelClass = StringHelper::basename($generator->modelClass); $searchModelClass = StringHelper::basename($generator->reallySearchNs); if ($modelClass === $searchModelClass) { $searchModelAlias = $searchModelClass . 'Search'; } /* @var $class ActiveRecordInterface */ $class = $generator->modelClass; $pks = $class::primaryKey(); $urlParams = $generator->generateUrlParams(); $actionParams = $generator->generateActionParams(); $actionParamComments = $generator->generateActionParamComments(); echo "<?php\n"; ?> namespace <?php echo StringHelper::dirname(str_replace('/', '\\', ltrim($generator->reallyControllerNs, '\\'))); ?> ; use Yii; <?php $attribute = ''; if ($attribute = $generator->hasUploadBehavior) { ?> use trntv\filekit\actions\DeleteAction; use trntv\filekit\actions\UploadAction; <?php } ?> use <?php echo ltrim($generator->modelClass, '\\');
/** * {@inheritdoc} */ public function generate() { $files = []; $relations = $this->generateRelations(); $db = $this->getDbConnection(); foreach ($this->getTableNames() as $tableName) { list($relations, $translations) = array_values($this->extractTranslations($tableName, $relations)); //var_dump($relations,$tableName);exit; $className = php_sapi_name() === 'cli' ? $this->generateClassName($tableName) : $this->modelClass; $queryClassName = $this->generateQuery ? $this->generateQueryClassName($className) : false; $tableSchema = $db->getTableSchema($tableName); $params = ['tableName' => $tableName, 'className' => $className, 'queryClassName' => $queryClassName, 'tableSchema' => $tableSchema, 'labels' => $this->generateLabels($tableSchema), 'hints' => $this->generateHints($tableSchema), 'rules' => $this->generateRules($tableSchema), 'relations' => isset($relations[$tableName]) ? $relations[$tableName] : [], 'ns' => $this->ns, 'enum' => $this->getEnum($tableSchema->columns)]; if (!empty($translations)) { $params['translation'] = $translations; } $params['blameable'] = $this->generateBlameable($tableSchema); $params['timestamp'] = $this->generateTimestamp($tableSchema); $files[] = new CodeFile(Yii::getAlias('@' . str_replace('\\', '/', $this->ns)) . '/base/' . $className . $this->baseClassSuffix . '.php', $this->render('model.php', $params)); $modelClassFile = Yii::getAlias('@' . str_replace('\\', '/', $this->ns)) . '/' . $className . '.php'; if ($this->generateModelClass || !is_file($modelClassFile)) { $files[] = new CodeFile($modelClassFile, $this->render('model-extended.php', $params)); } if ($queryClassName) { $queryClassFile = Yii::getAlias('@' . str_replace('\\', '/', $this->queryNs)) . '/' . $queryClassName . '.php'; if ($this->generateModelClass || !is_file($queryClassFile)) { $params = ['className' => $queryClassName, 'modelClassName' => $className]; $files[] = new CodeFile($queryClassFile, $this->render('query.php', $params)); } } /* * create gii/[name]GiiantModel.json with actual form data */ $suffix = str_replace(' ', '', $this->getName()); $formDataDir = Yii::getAlias('@' . str_replace('\\', '/', $this->ns)); $formDataFile = StringHelper::dirname($formDataDir) . '/gii' . '/' . $tableName . $suffix . '.json'; $formData = json_encode(SaveForm::getFormAttributesValues($this, $this->formAttributes())); $files[] = new CodeFile($formDataFile, $formData); } return $files; }
/** * @param \phpDocumentor\Reflection\InterfaceReflector $reflector * @param Context $context * @param array $config */ public function __construct($reflector = null, $context = null, $config = []) { parent::__construct($reflector, $context, $config); if ($reflector === null) { return; } foreach ($this->tags as $i => $tag) { if ($tag instanceof AuthorTag) { $this->authors[$tag->getAuthorName()] = $tag->getAuthorEmail(); unset($this->tags[$i]); } else { if ($tag->getName() == 'package') { $this->namespace = $tag->getContent(); unset($this->tags[$i]); } } } if (empty($this->namespace)) { $this->namespace = trim(StringHelper::dirname($this->name), '\\'); } foreach ($reflector->getProperties() as $propertyReflector) { if ($propertyReflector->getVisibility() != 'private') { $property = new PropertyDoc($propertyReflector, $context, ['sourceFile' => $this->sourceFile]); $property->definedBy = $this->name; $this->properties[$property->name] = $property; } } foreach ($reflector->getMethods() as $methodReflector) { if ($methodReflector->getVisibility() != 'private') { $method = new MethodDoc($methodReflector, $context, ['sourceFile' => $this->sourceFile]); $method->definedBy = $this->name; $this->methods[$method->name] = $method; } } }
/* @var $generator yii\gii\generators\crud\Generator */ $modelClass = StringHelper::basename($generator->modelClass); $searchModelClass = StringHelper::basename($generator->searchModelClass); if ($modelClass === $searchModelClass) { $modelAlias = $modelClass . 'Model'; } $rules = $generator->generateSearchRules(); $labels = $generator->generateSearchLabels(); $searchAttributes = $generator->getSearchAttributes(); $searchConditions = $generator->generateSearchConditions(); echo "<?php\n"; ?> namespace <?= StringHelper::dirname(ltrim($generator->searchModelClass, '\\')) ?>; use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; use <?= ltrim($generator->modelClass, '\\') . (isset($modelAlias) ? " as $modelAlias" : "") ?>; /** * <?= $searchModelClass ?> represents the model behind the search form about `<?= $generator->modelClass ?>`. */ class <?= $searchModelClass ?> extends <?= isset($modelAlias) ? $modelAlias : $modelClass ?> { /** * @inheritdoc */
/** * Composes asset bundle class source code. * @param array $config asset bundle config. * @return string class source code. */ protected function composeAssetBundleClassSource(array &$config) { $config = array_merge(['namespace' => StringHelper::dirname(get_class($this)), 'class' => 'AppAsset', 'basePath' => $this->testFilePath, 'baseUrl' => '', 'css' => [], 'js' => [], 'depends' => []], $config); foreach ($config as $name => $value) { if (is_array($value)) { $config[$name] = var_export($value, true); } } $source = <<<EOL namespace {$config['namespace']}; use yii\\web\\AssetBundle; class {$config['class']} extends AssetBundle { public \$basePath = '{$config['basePath']}'; public \$baseUrl = '{$config['baseUrl']}'; public \$css = {$config['css']}; public \$js = {$config['js']}; public \$depends = {$config['depends']}; } EOL; return $source; }
public function getWidgetNameSpace() { // Yii::info(StringHelper::dirname(ltrim($this->controllerClass, '\\'))); return dirname(StringHelper::dirname(ltrim($this->controllerClass, '\\'))) . '\\widgets'; }
/* @var $this yii\web\View */ /* @var $generator \mootensai\enhancedgii\model\Generator */ $modelClass = StringHelper::basename($generator->modelClass); $searchModelClass = StringHelper::basename($generator->searchModelClass); if ($modelClass === $searchModelClass) { $modelAlias = $modelClass . 'Model'; } $rules = $generator->generateSearchRules(); $labels = $generator->generateSearchLabels(); $searchAttributes = $generator->getSearchAttributes(); $searchConditions = $generator->generateSearchConditions(); echo "<?php\n"; ?> namespace <?php echo StringHelper::dirname(ltrim($generator->nsSearchModel, '\\')); ?> ; use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; use <?php echo ltrim($generator->searchModelClass, '\\') . (isset($modelAlias) ? " as {$modelAlias}" : ""); ?> ; /** * <?php echo $searchModelClass; ?>
/** * Retrieves only basename of class fqn * @param string $fqn */ public static function ns($fqn) { return trim(StringHelper::dirname($fqn), '\\'); }
/** * Returns the ID of action, which should be used for return redirect. * If action belongs to another controller or does not exist in current controller - 'index' is returned. * @param string $defaultActionId default action ID. * @return string action ID. */ public function getReturnAction($defaultActionId = 'index') { if ($this->returnAction !== null) { return $this->returnAction; } $sessionKey = '__adminReturnAction'; $actionId = Yii::$app->getSession()->get($sessionKey, $defaultActionId); $actionId = trim($actionId, '/'); if ($actionId === 'index') { return $actionId; } if (strpos($actionId, '/') !== false) { $controllerId = StringHelper::dirname($actionId); if ($controllerId !== $this->controller->getUniqueId()) { return 'index'; } $actionId = StringHelper::basename($actionId); } if (!$this->actionExists($actionId)) { return 'index'; } return $actionId; }
<?php $types = $renderer->getNavTypes(isset($type) ? $type : null, $types); ksort($types); $nav = []; $subNav = []; foreach ($types as $i => $class) { $namespace = $class->namespace; preg_match('/^([a-zA-Z0-9]+\\\\[a-zA-Z0-9]*)/', $class->namespace, $matches); #var_dump($class->namespace,$matches); if (isset($matches[1])) { $namespace = $matches[1]; } else { $namespace = ''; } $subNamespace = StringHelper::dirname($class->name); $subLabel = StringHelper::dirname(str_replace($namespace, '', $class->name)); if (empty($subNamespace)) { $subNamespace = $class->namespace; $subLabel = '.'; } if (empty($namespace)) { $namespace = 'Not namespaced classes'; } if (!isset($nav[$namespace])) { $nav[$namespace] = ['label' => $namespace, 'url' => '#']; } if (!isset($subNav[$subNamespace])) { $subNav[$subNamespace] = ['label' => $subLabel, 'url' => '#', 'items' => []]; $nav[$namespace]['items'][] =& $subNav[$subNamespace]; } $subNav[$subNamespace]['items'][] = ['label' => StringHelper::basename($class->name), 'url' => './' . $renderer->generateApiUrl($class->name), 'active' => isset($type) && $class->name == $type->name];
/* @var $this yii\web\View */ /* @var $generator yii\gii\generators\crud\Generator */ $modelClass = StringHelper::basename($generator->modelClass); $searchModelClass = StringHelper::basename($generator->searchModelClass); if ($modelClass === $searchModelClass) { $modelAlias = $modelClass . 'Model'; } $rules = $generator->generateSearchRules(); $labels = $generator->generateSearchLabels(); $searchAttributes = $generator->getSearchAttributes(); $searchConditions = $generator->generateSearchConditions(); echo "<?php\n"; ?> namespace <?php echo StringHelper::dirname(ltrim($generator->searchModelClass, '\\')); ?> ; use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; use <?php echo ltrim($generator->modelClass, '\\') . (isset($modelAlias) ? " as {$modelAlias}" : ""); ?> ; /** * <?php echo $searchModelClass; ?>
$traitClass = StringHelper::basename($generator->traitClass); $controllerClass = StringHelper::basename($generator->controllerClass); $modelClass = StringHelper::basename($generator->modelClass); $searchModelClass = StringHelper::basename($generator->searchModelClass); if ($modelClass === $searchModelClass) { $searchModelAlias = $searchModelClass . 'Search'; } $pks = $generator->getTableSchema()->primaryKey; $urlParams = $generator->generateUrlParams(); $actionParams = $generator->generateActionParams(); $actionParamComments = $generator->generateActionParamComments(); echo "<?php\n"; ?> namespace <?php echo StringHelper::dirname(ltrim($generator->traitClass, '\\')); ?> ; use Yii; use <?php echo ltrim($generator->modelClass, '\\'); ?> ; <?php if (!empty($generator->searchModelClass)) { ?> use <?php echo ltrim($generator->searchModelClass, '\\') . (isset($searchModelAlias) ? " as {$searchModelAlias}" : ""); ?> ;