Get the stub file for the generator.

@param null $name
@return string
497605
protected function getStub($name = null)
    {
        if ($name == $this->qualifyClass('ModelPolicy')) return __DIR__.'/stubs/policy.model.stub';

        return $this->option('model')
            ? __DIR__.'/stubs/policy.stub'
            : parent::getStub();
    }
504998
public function getModule($name)
	{
	    $name = $this->parseModuleAlias($name);
	    $uid = 'module.' . $name;
	    
	    if ($this->hasModule($name)) {
		    /* @var $module Module */
	        return $this->get($uid);
		} else {
		    $basePath = rtrim($this->basePath, '\\/' ) . '/' . $name;
		    if (file_exists($basePath)) {
		        
		        $this->setModule($name, $basePath);
		        
		        return $this->get($uid);;
		    }
		}
		
		return null;
	}
1337455
protected function buildClass($name)
    {
        $stub = $this->files->get($this->getStub());

        return $this->option('parent')
                        ? $this->replaceNamespace($stub, $name)->replaceParentClass($stub)->replaceParentFqcn($stub)->replaceClass($stub, $name)
                        : $this->replaceNamespace($stub, $name)->replaceClass($stub, $name);
    }
189744
public function getViewFile($name)
    {
        list($plugin, $name) = $this->pluginSplit($name);
        $return = null;
        foreach ($this->_paths($plugin) as $path) {
            $viewFile = FS::clean($path . $name . $this->_ext);
            if (FS::isFile($viewFile)) {
                $return = $this->_checkFilePath($viewFile, $path);
                break;
            }
        }

        return $return;
    }
512627
public function getPlugin($name)
    {
        foreach (array_keys(get_plugins()) as $file) {
            // Logic taken from WP-CLI.
            if ($file === "{$name}.php" || ($name && $file === $name) || (dirname($file) === $name && $name !== '.')) {
                return $file;
            }
        }

        return '';
    }
659474
final public function output(string $name = null)
    {
        $result = implode(static::EOL, $this->registries) . static::EOL
            . static::EOF;

        if ($name === null) {
            return $result;
        }

        Utils::checkOutput(pathinfo($name)['extension'] ?? '');

        header('Content-Type: text/plain');
        header('Content-Length: ' . strlen($result));
        header('Content-Disposition: attachment; filename="' . $name . '"');
        echo $result;
    }
549892
protected function makeTransformer(string $name, string $stub):string
    {
        $stub = $this->replaceNamespace($stub);
        $stub = $this->replaceClass($stub, $name);
        $stub = $this->replaceModel($stub, $name);

        return $stub;
    }
509198
protected function buildClass($name): string
    {
        $stub = parent::buildClass($name);

        $model = $this->option('model') ?? $this->modelName = $this->ask('What is your model?');

        $transformer = $this->option('transformer') ?? $this->transformerName = $this->ask('What is your transformer?');

        return $this->replaceClasses($stub, $model, $transformer);
    }
1127230
public function getRecord($name = null)
    {
        $recordName = $name ?: $this->record;

        if ($recordName === false) {
            return new NullRecord();
        }

        $recordName = $recordName ?: $this->getName();

        $mapper = $this->getDataMapper($name);

        if ($mapper instanceof AbstractDatabaseMapperProxy) {
            $mapper = $mapper::getInstance();
        }

        // (1) If name is class, just new it.
        if (class_exists($recordName)) {
            return new $recordName($this->table, $this->keys, $mapper);
        }

        // (2): Find object from registered namespaces
        if ($record = RecordResolver::create($recordName, $this->table, $this->keys, $mapper)) {
            return $record;
        }

        $errors[] = sprintf(
            'Record: "%s" not found from namespaces: (%s)',
            $recordName,
            implode(" |\n ", RecordResolver::dumpNamespaces())
        );

        // (3): Find from package directory.
        $class = sprintf(
            '%s\Record\%sRecord',
            MvcHelper::getPackageNamespace(static::class, 2),
            ucfirst($recordName)
        );

        if (class_exists($class)) {
            return new $class($this->table, $this->keys, $mapper);
        }

        $errors[] = sprintf('Class: %s not exists.', $class);

        // If name is NULL and this model prepared a default record name.
        // We must throw exception to tell developers record not found.
        if (!$name && $this->record) {
            throw new \LogicException(implode("\n- ", $errors));
        }

        // If name not NULL, set it as table name, otherwise use pre-set table property.
        $table = $name ?: $this->table;

        if (!$table) {
            throw new \LogicException(
                'Please add table property to ' . get_called_class() . " to support Record object. \n" .
                implode("\n- ", $errors)
            );
        }

        // (4): If name is null, we get default object with table name provided.
        return new Record($table, $this->keys, $mapper);
    }
265099
public function getField(string $name)
    {
        $name = trim($name);
        if (!$this->isFieldSet($name)) {
            return null;
        }

        $field_key = array_search($name, $this->keys);
        return $this->method[$field_key] ?? $_FILES[$field_key];
    }
987890
protected function buildClass($name)
    {
        $stub = parent::buildClass($name);

        $modelName = $this->getModelClass($name);

        $this->replaceModelNamespace($stub, $modelName)
             ->replaceModelClass($stub, $modelName)
             ->replaceBaseRepositoryNamespace($stub, $this->base)
             ->replaceBaseRepositoryClass($stub, $this->base);

        return $stub;
    }
1112844
private function resolveFileName($name): string
    {
        $filename = $this->getFilename($name);
        if ($filename === false) {
            throw new LoaderError(sprintf('Template "%s" is not defined.', $name));
        }

        return $filename;
    }
892059
protected function getExtendFile($name) {
        if (strpos($name, '@') === 0) {
            return $this->factory->invokeTheme('getFile', [substr($name, 1)]);
        }
        if (strpos($name, './') === 0) {
            return $this->file->getDirectory()
                ->getFile($this->factory->fileSuffix(substr($name, 2)));
        }
        if (strpos($name, '../') === 0) {
            return $this->file->getDirectory()->parent()
                ->getFile($this->factory->fileSuffix($name));
        }
        return $name;
    }
358629
protected function buildClass($name)
    {
        $stub = $this->files->get($this->getStub());

        $viewPath = $this->option('view-path') ? $this->option('view-path') . '.' : '';
        $crudName = strtolower($this->option('crud-name'));
        $crudNameSingular = str_singular($crudName);
        $modelName = $this->option('model-name');
        $routeGroup = ($this->option('route-group')) ? $this->option('route-group') . '/' : '';

        $validationRules = '';
        if ($this->option('required-fields') != '') {
            $validationRules = "\$this->validate(\$request, " . $this->option('required-fields') . ");\n";
        }

        return $this->replaceNamespace($stub, $name)
            ->replaceViewPath($stub, $viewPath)
            ->replaceCrudName($stub, $crudName)
            ->replaceCrudNameSingular($stub, $crudNameSingular)
            ->replaceModelName($stub, $modelName)
            ->replaceRouteGroup($stub, $routeGroup)
            ->replaceValidationRules($stub, $validationRules)
            ->replaceClass($stub, $name);
    }
850351
public function getSluggedFileName($name)
    {
        $fileNameExploded = explode(".", $name);
        $extension = array_pop($fileNameExploded);
        $fileNameExploded = implode(".", $fileNameExploded);

        return $this->slugify($fileNameExploded) . "." . $extension;
    }
701900
protected function getViewContent($name)
    {
        if (!$stub = $this->getViewStub($name)) {
            return '';
        }

        return strtr($stub, $this->getCommonReplacements());
    }
1063021
public function getUploadPath($name = null)
    {
        if (is_null($name)) {
            return '';
        } else {
            if (!isset($this->cache[$name])) {
                $this->cache[$name] = Yii::$app->pathManager->getPath($this->namespace);
            }
        }
        return $this->cache[$name]->getFullPath($name);
    }