Generates the new.html.twig template in the final bundle.

@param string $dir The path to the folder that hosts templates in the bundle
557155
private function generateNewView($dir)
    {
        $this->renderFile('views/new.html.twig', $dir.'/new.html.twig', array(
            'dir' => $this->skeletonDir,
            'route_prefix' => $this->routePrefix,
            'route_name_prefix' => $this->routeNamePrefix,
            'document' => $this->document,
            'actions' => $this->actions,
        ));
    }
39186
public function generate($namespace, $bundle, $dir)
    {
        $dir .= '/' . strtr($namespace, '\\', '/');
        if (file_exists($dir)) {
            throw new \RuntimeException(sprintf('Unable to generate the bundle as the target directory "%s" is not empty.', realpath($dir)));
        }

        $basename = substr($bundle, 0, -6);
        $parameters = array(
            'namespace' => $namespace,
            'bundle' => $bundle,
            'bundle_basename' => $basename,
            'extension_alias' => Container::underscore($basename),
        );

        $this->renderFile('/bundle/Bundle.php', $dir . '/' . $bundle . '.php', $parameters);
        $this->renderFile('/bundle/Extension.php', $dir . '/DependencyInjection/' . $basename . 'Extension.php', $parameters);
        $this->renderFile('/bundle/Configuration.php', $dir . '/DependencyInjection/Configuration.php', $parameters);
        $this->renderFile('/bundle/DefaultController.php', $dir . '/Controller/DefaultController.php', $parameters);
        $this->renderFile('/bundle/index.html.twig', $dir . '/Resources/views/Default/index.html.twig', $parameters);

        $this->renderFile('/bundle/services.yml', $dir . '/Resources/config/services.yml', $parameters);
        $this->renderFile('/bundle/routing.yml', $dir . '/Resources/config/routing.yml', $parameters);
    }
526701
private function copyTemplates()
    {
        $dirPath = $this->bundle->getPath();
        $this->filesystem->copy($this->skeletonDir . '/Resources/views/Pages/FormPage/view.html.twig', $dirPath . '/Resources/views/Pages/'.$this->entity.'/view.html.twig', true);
        $this->filesystem->copy($this->skeletonDir . '/Resources/views/Pages/FormPage/pagetemplate.html.twig', $dirPath . '/Resources/views/Pages/'.$this->entity.'/pagetemplate.html.twig', true);
        GeneratorUtils::replace('~~~BUNDLE~~~', $this->bundle->getName(), $dirPath . '/Resources/views/Pages/'.$this->entity.'/pagetemplate.html.twig');

        GeneratorUtils::prepend("{% extends '" . $this->bundle->getName() .":Page:layout.html.twig' %}\n", $dirPath . '/Resources/views/Pages/'.$this->entity.'/view.html.twig');
    }
577892
public function addComposerPackageFromDirectory(Dir $dir) {
    $package = $this->getComposerPackageReader()->fromDirectory($dir);
    
    $this->addPackage($package);
    
    return $package;
  }
946663
protected function generateMapperFileAbstract($dir)
    {
        $file = $dir . '/' . $this->config->getClassname() . 'MapperAbstract.php';

        if (!is_readable($file) && false === file_put_contents($file, '')) {
            throw new \RuntimeException('Cannot create empty class file: ' . $file);
        }

        $content = '<?php

/**
 * Copyright (c) 2010-' . date('Y') . ' ' . $this->config->getAuthor() . '
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ' . $this->baseNamespace . 'Mapper\\' . $this->config->getNamespace() . '\Abstracts;

use Eureka\Component\Orm\DataMapper\MapperAbstract;
use ' . $this->baseNamespace . 'Data\\' . $this->config->getNamespace() . '\\' . $this->config->getClassname() . ';

/**
 * /!\ AUTO GENERATED FILE. DO NOT EDIT THIS FILE.
 * THIS FILE IS OVERWRITTEN WHEN THE ORM SCRIPT GENERATOR IS RAN.
 * You can add you specific code in child class: ' . $this->config->getClassname() . '
 *
 * @author  ' . $this->config->getAuthor() . '
 * @version ' . $this->config->getVersion() . '
 */
abstract class ' . $this->config->getClassname() . 'MapperAbstract extends MapperAbstract
{
    /**
     * @var string $dataClass Name of class use to instance DataMapper Data class.
     */
    protected $dataClass = \'\\' . $this->baseNamespace . 'Data\\' . $this->config->getNamespace() . '\\' . $this->config->getClassname() . '\';

    /**
     * @var string $databaseConfig Database config name
     */
    protected $databaseConfig = \'' . $this->config->getDbConfig() . '\';

    /**
     * @var array $fields List of fields
     */
    protected $table = \'' . $this->config->getDbTable() . '\';

    /**
     * @var array $fields List of fields
     */
    protected $fields = array(
' . $this->vars['db_fields'] . '
    );

    /**
     * @var array $primaryKeys List of primary keys
     */
    protected $primaryKeys = array(
' . $this->vars['db_primary_keys'] . '
    );

    /**
     * @var array $primaryKeys List of primary keys
     */
    protected $dataNamesMap = array(
' . $this->vars['data_names_map'] . '
    );

    /**
     * @var string $cacheName Name of cache config to use.
     */
    protected $cacheName = \'' . $this->config->getCacheName() . '\';

    /**
     * @var bool $isCacheEnabled
     */
    protected $isCacheEnabled = ' . var_export($this->config->hasCache(), true) . ';

    /**
     * Get first row corresponding of the id.
     *
     * @param  int $id
     * @return ' . $this->config->getClassname() . '
     */
    public function findById($id)
    {
        return parent::findById($id);
    }

    /**
     * Get first row corresponding of the primary keys.
     *
     * @param  array $primaryKeys
     * @return ' . $this->config->getClassname() . '
     */
    public function findByKeys($primaryKeys)
    {
        return parent::findByKeys($primaryKeys);
    }

    /**
     * Select all rows corresponding of where clause.
     *
     * @return ' . $this->config->getClassname() . '[] List of row.
     */
    public function select()
    {
        return parent::select();
    }

    /**
     * Select first rows corresponding to where clause.
     *
     * @return ' . $this->config->getClassname() . '
     */
    public function selectOne()
    {
        return parent::selectOne();
    }

    /**
     * Fetch rows for specified query.
     *
     * @param string $query
     * @return ' . $this->config->getClassname() . '[] Array of model_base object for query.
     */
    public function query($query)
    {
        return parent::query($query);
    }

    /**
     * Create new instance of extended DataAbstract class & return it.
     *
     * @param  \stdClass $row
     * @param  bool      $exists
     * @return ' . $this->config->getClassname() . '
     */
    public function newDataInstance(\stdClass $row = null, $exists = false)
    {
        return parent::newDataInstance($row, $exists);
    }
}
';
        if (false === file_put_contents($file, $content)) {
            throw new \RuntimeException('Unable to write file content! (file: ' . $file . ')');
        }
    }
616977
public static function rmdir( $dir ) {
		$files = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS ),
			RecursiveIteratorIterator::CHILD_FIRST
		);

		foreach ( $files as $fileinfo ) {
			$todo = $fileinfo->isDir() ? 'rmdir' : 'unlink';
			$todo( $fileinfo->getRealPath() );
		}
		rmdir( $dir );
	}
365371
function Template( name, dir){
  this.name = name;
  if( name){
    this.view = this.load( 
      util.format(
        '%s/%s/%s.%s', 
        dir, name, name, 'html'
      )
    );
  }
  return this;
}
367864
public function add_template_directory($directory, $namespace = null) {
		if ($this->filesystem_loader === null) {
			$this->filesystem_loader = new \Twig_Loader_Filesystem($directory);
		}

		if ($namespace === null) {
			$this->filesystem_loader->addPath($directory);
		} else {
			$this->filesystem_loader->addPath($directory, $namespace);
		}
	}
835057
protected function generateDataFile($dir)
    {
        $file = $dir . '/' . $this->config->getClassname() . '.php';

        if (file_exists($file)) {
            return;
        }

        if (!is_readable($file) && false === file_put_contents($file, '')) {
            throw new \RuntimeException('Cannot create empty class file: ' . $file);
        }

        $content = '<?php

/**
 * Copyright (c) 2010-' . date('Y') . ' ' . $this->config->getAuthor() . '
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ' . $this->baseNamespace . 'Data\\' . $this->config->getNamespace() . ';

/**
 * DataMapper Data class for table "' . $this->config->getDbTable() . '"
 *
 * @author  ' . $this->config->getAuthor() . '
 * @version ' . $this->config->getVersion() . '
 */
class ' . $this->config->getClassname() . ' extends Abstracts\\' . $this->config->getClassname() . 'Abstract
{
}
';
        if (false === file_put_contents($file, $content)) {
            throw new \RuntimeException('Unable to write file content! (file: ' . $file . ')');
        }
    }
529864
public static function createDir($dir)
    {
        try {
            if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
                throw new \Exception(t('Can\'t create directory ') . $dir);
            }
        } catch (\Exception $e) {
            Logger::log($e->getMessage(), LOG_WARNING);
            if (!file_exists(dirname($dir))) {
                throw new GeneratorException($e->getMessage() . $dir);
            }
        }
    }
1340874
public static function setApplicationDir(array $dir)
    {
        if (DIRECTORY_SEPARATOR == '\\') {//windows
            array_walk($dir, function (&$val) {
                $val = str_replace('/', DIRECTORY_SEPARATOR, $val);
            });
        }
        self::$appDir = array_merge(self::$appDir, $dir);
    }
241546
public function generate( $directory = '.'){
        $chapters = $this->generateClassMdFromLoadedClasses();
        $this->rootPage = new models\NamespaceMd( $this->rootNamespace, $chapters);
        $this->rootPage->setDirectory( $directory);
        $this->rootPage->write();
    }
840818
public function htmllize_file_tree($dir) {
        if (empty($dir['subdirs']) and empty($dir['files'])) {
            return '';
        }
        $result = '<ul>';
        foreach ($dir['subdirs'] as $subdir) {
            $result .= '<li>'.s($subdir['dirname']).' '.$this->htmllize_file_tree($subdir).'</li>';
        }
        foreach ($dir['files'] as $file) {
            $filename = $file->get_filename();
            $result .= '<li><span>'.html_writer::link($file->fileurl, $filename).'</span></li>';
        }
        $result .= '</ul>';

        return $result;
    }
898898
function _save_dir($dir)
    {
        // preg_replace('#^/|/(?=/)|/$#', '', $dir) == str_replace('//', '/', trim($dir, '/'))
        $dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $dir));

        $temp = &$this->dirs;
        foreach ($dirs as $dir) {
            if (!isset($temp[$dir])) {
                $temp[$dir] = array();
            }
            $temp = &$temp[$dir];
        }
    }
1354330
public function generateTemplate($dir, $themeName, $templateName, $assets)
    {
        $themeBasename = str_replace('Bundle', '', $themeName);
        $extensionAlias = Container::underscore($themeBasename);

        $parameters = array(
            'theme_name' => $themeName,
            'template_name' => $templateName,
            'extension_alias' => $extensionAlias,
            'assets' => $assets,
        );

        $templateFile = $templateName.'.xml';
        $this->setSkeletonDirs($this->themeSkeletonDir);
        $this->renderFile('template.xml', $dir . '/' . $templateFile, $parameters);

        return sprintf('The template <info>%s</info> has been generated into <info>%s</info>', $templateFile, $dir);
    }
1212986
public function warmUp($cacheDir)
    {
        $templates = array();

        /** @var \Symfony\Component\Templating\TemplateReferenceInterface $template */
        foreach ($this->finder->findAllTemplates() as $template) {
            $templates[$template->getLogicalName()] = $this->locator->locate($template);

            if (!$template instanceof TemplateReference) {
                continue;
            }

            $bundle = $template->get('bundle');
            if (empty($bundle)) {
                continue;
            }
            // Resolve the base bundle
            $bundles = $this->kernel->getBundle($bundle, false);
            $baseBundle = end($bundles);

            // Resolve the base path
            $relativePath = substr($template->getPath(), strlen($bundle) + 1);
            $baseBundlePath = $baseBundle->getPath() . $relativePath;

            // Check if the base is the same if not add the override to the template cache
            if ($templates[$template->getLogicalName()] !== $baseBundlePath) {
                $templates['!'.$template->getLogicalName()] = $baseBundlePath;
            }
        }

        $this->writeCacheFile($cacheDir.'/templates.php', sprintf('<?php return %s;', var_export($templates, true)));
    }
1014975
public function initialize($template, $directory, $file = 'deploy.php', $params = [])
    {
        if (!isset($this->templates[$template])) {
            throw TemplateNotFoundException::create($template, array_keys($this->templates));
        }

        $this->checkDirectoryBeforeInitialize($directory);
        $this->checkFileBeforeInitialize($directory, $file);

        $filePath = $directory . '/' . $file;

        $this->templates[$template]->initialize($filePath, $params);

        return $filePath;
    }