Generate template file, same name.

@param string $path
@param array $arguments
180366
public function templateFile($path, array $arguments = [])
    {
        $this->file($path)->template($this->makePath($path), $arguments);
    }
625207
protected function templatePath($path, array $path_vars = []) {
    if (strpos($path, '{') !== false) {
      extract($path_vars);
      preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches);
      if (!empty($matches[1])) {
        foreach ($matches[1] as $var) {
          $path = str_replace('{$' . $var . '}', $$var, $path);
        }
      }
    }

    return $path;
  }
605392
private function addTwigPath($path, array $options = [])
    {
        if ($path === 'templates' && $this->pathAdded) {
            return;
        }

        $app = $this->getContainer();

        $position = isset($options['position']) ? $options['position'] : 'append';
        $namespace = isset($options['namespace']) ? $options['namespace'] : FilesystemLoader::MAIN_NAMESPACE;

        $dir = $this->getBaseDirectory()->getDir($path);
        if (!$dir->exists()) {
            return;
        }
        try {
            if ($position === 'prepend') {
                $app['twig.loader.bolt_filesystem']->prependDir($dir, $namespace);
            } else {
                $app['twig.loader.bolt_filesystem']->addDir($dir, $namespace);
            }
        } catch (LoaderError $e) {
            $app['logger.system']->critical(sprintf('%s was unable to add the Twig path %s. %s', $this->getName(), $path, $e->getMessage()), ['event' => 'exception', 'exception' => $e]);
        }
    }
107828
protected function generateFiles($path)
    {
        //
        // Generate the custom helpers file.

        $content ='<?php

//----------------------------------------------------------------------
// Custom Helpers
//----------------------------------------------------------------------
';

        $filePath = $path .DS .'Support' .DS .'helpers.php';

        $this->files->put($filePath, $content);

        //
        // Generate the Language files.

        $content ='<?php

return array (
);';

        $languages = $this->container['config']->get('languages', array());

        foreach (array_keys($languages) as $code) {
            $filePath = $path .DS .'Language' .DS .strtoupper($code) .DS .'messages.php';

            $this->files->put($filePath, $content);
        }
    }
647972
protected static function getTemplate($path)
    {
        if(file_exists($path))
            $template = file_get_contents($path);
        elseif(file_exists(__DIR__ . '/templates/' . $path))
            $template = file_get_contents(__DIR__ . '/templates/' . $path);
        else
            throw new \InvalidArgumentException('Template file not found.');

        return $template;
    }
558428
protected function _templatePath($path, array $vars = array())
    {
        if (strpos($path, '{') !== false) {
            preg_match_all('#\{\$([_a-z0-9]*)\}#i', $path, $matches);
            if (!empty($matches[1])) {
                foreach ($matches[1] as $var) {
                    $path = str_replace('{$' . $var . '}', isset($vars[$var]) ? $vars[$var] : null, $path);
                }
            }
        }
        return $path;
    }
333614
protected  function createManifest($path, $files)
    {
        $data = [ ];
        foreach ( $files as $file ) {
            $data[] = [
                'type'      => $file[ 'type' ],
                'name'      => $file[ 'entity' ][ 'name' ],
                'full_name' => $file[ 'entity' ][ 'full_name' ],
                'namespace' => $file[ 'entity' ][ 'namespace' ],
            ];
        }
        $this->fs->put($path, Util::exportArray($data));
        return $data;
    }
453711
protected function generateUrl($path, array $parameters = array())
    {
        $ampersand = '&';
        $schema = '';

        return
            \Yii::app()->getRequest()->getHostInfo($schema).
            \Yii::app()->createUrl(trim($path,'/'),$parameters, $ampersand)
        ;
    }
1162549
protected function create(Array $arguments=[])
	{
		$migrationsDirectory = $this->cmd->getConfigOpt('migrations_storage');
		$templateTags = [];

		$migrationName = $this->cmd->question('Migration filename?');
		$filename = trim($migrationName);

		$path = $migrationsDirectory . '/' . $filename . '.php';

		if (file_exists($path)) {
			throw new MigrationFileInvalidException(
				sprintf(
					'Migration file [%s] exists.',
					$filename
				)
			);
		}

		$templateTags['phx:class'] = Helper::getQualifiedClassName($filename);

		$builder = new TemplateBuilder($this->cmd, $this->env);
		$builder->createClassTemplate('migration', $filename, $migrationsDirectory, $templateTags);

		// After migration class has been created, the record needs to go to the database and be set to pending.
		$model = new Model();
		$model->class_name = $templateTags['phx:class'];
		$model->status = Attribute::STATUS_PENDING;
		$model->path = $path;
		$model->save();

		$this->env->sendOutput('Created migration is now pending', 'green');
	}
856017
protected function generateExport($path = null)
    {
        $temporary = $this->getTemporaryFilePath();

        // Create new csv file
        $resource = fopen($temporary, 'w');

        if (false === $resource) {
            throw new RuntimeException("Failed to open temporary export file '{$temporary}'");
        }

        try {
            $this->writeCsvContent($resource);

        } catch (Exception $e) {

            throw $e;

        } finally {

            fclose($resource);
        }

        return $temporary;
    }
528098
protected function generate($path, $filename)
    {
        $generator = new ClassGenerator();
        $generator->generate(file_get_contents($filename));
        $fqcn = $generator->getClassBuilder()->getClass();
        $compiler = new Compiler();
        $class = $compiler->parseClassName($fqcn);
        $path = $this->createDirFromNamespace($path, $class['namespace']);
        $output = $path . '/' . $class['classname'] . '.php';
        $generator->write($output);
    }
385988
public function setTemplatePathAndFilename($templatePathAndFilename)
    {
        $this->baseRenderingContext->getTemplatePaths()->setTemplatePathAndFilename($templatePathAndFilename);

        $partialRootPaths = $this->baseRenderingContext->getTemplatePaths()->getPartialRootPaths();
        $layoutRootPaths = $this->baseRenderingContext->getTemplatePaths()->getLayoutRootPaths();
        array_unshift($partialRootPaths, Files::concatenatePaths([dirname($templatePathAndFilename), 'Partials']));
        array_unshift($layoutRootPaths, Files::concatenatePaths([dirname($templatePathAndFilename), 'Layouts']));
        $this->baseRenderingContext->getTemplatePaths()->setPartialRootPaths($partialRootPaths);
        $this->baseRenderingContext->getTemplatePaths()->setLayoutRootPaths($layoutRootPaths);
    }
1351182
public static function inc($path, $extensionId = null, $data = array()) {
        $context = \Context::getInstance();
        if (!is_null($extensionId) && $extensionId != $context->getExtensionName()) {
            // template is within different extension, change context
            $formerContext = $context->getExtensionName();
            $context->setExtensionName($extensionId);
        }

        if(count($data) > 0){
            \RenderContext::pushContext($data);
        }
        
        $absPath = self::getTemplate($path, $extensionId);
        if (file_exists($absPath)) {
            include($absPath);
        } else {
            \common_Logger::w('Failed to include "'.$absPath.'" in template');
        }
        // restore context
        if (isset($formerContext)) {
            $context->setExtensionName($formerContext);
        }
    }
838643
public function setTemplatePaths(array $paths)
    {
        $this->paths = [];
        foreach ($paths as $namespace => $path) {
            $this->addTemplatePath($namespace, $path);
        }
    }
498336
public function setPath(string $path)
    {
        $this->path = $path;
        
        // update path to templates and preload list of templates.
        $this->contentPath = $this->path . DIR_CONTENT_BASENAME;
        $this->templatesPath = $this->contentPath . DIR_TEMPLATES_BASENAME;
        
        $this->templates = File::listFilesRecursively($this->templatesPath, false, EXT_PART, EXT_PAGE);
    }
381105
protected function setServicesFile($path, $template, array $vars) {
    $this->addServicesFile()
      ->path($path)
      ->template($template)
      ->vars($vars);
  }
871884
public function load(string $path, string ...$paths): void
    {
        array_unshift($paths, $path);
        foreach ($paths as $path) {
            if (!is_readable($path) || is_dir($path) || ($contents = parse_ini_file($path, false)) === false) {
                throw new InvalidArgumentException("{$path} is not a readable file.");
            }
            $this->populate($contents);
        }
    }