generate

Generate structure file.

@see BaseGenerator
332065
public function generate(ParameterHolder $input, array $output = [])
    {
        $table_oid          = $this->checkRelationInformation();
        $field_information = $this->getFieldInformation($table_oid);
        $primary_key        = $this->getPrimaryKey($table_oid);
        $table_comment      = $this->getTableComment($table_oid);

        if ($table_comment === null) {
            $table_comment = <<<TEXT

Class and fields comments are inspected from table and fields comments. Just add comments in your database and they will appear here.
@see http://www.postgresql.org/docs/9.0/static/sql-comment.html
TEXT;
        }

        $this
            ->outputFileCreation($output)
            ->saveFile(
                $this->filename,
                $this->mergeTemplate(
                    [
                        'namespace'      => $this->namespace,
                        'class_name'     => $input->getParameter('class_name', Inflector::studlyCaps($this->relation)),
                        'relation'       => sprintf("%s.%s", $this->schema, $this->relation),
                        'primary_key'    => join(
                            ', ',
                            array_map(
                                function ($val) { return sprintf("'%s'", $val); },
                                $primary_key
                            )
                        ),
                        'add_fields'     => $this->formatAddFields($field_information),
                        'table_comment'  => $this->createPhpDocBlockFromText($table_comment),
                        'fields_comment' => $this->formatFieldsComment($field_information),
                    ]
                )
            );

        return $output;
    }
974916
def generate(env):
    """"""
    env['BUILDERS']['RMIC'] = RMICBuilder

    env['RMIC']            = 'rmic'
    env['RMICFLAGS']       = SCons.Util.CLVar('')
    env['RMICCOM']         = '$RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} -classpath ${SOURCE.attributes.java_classdir} ${SOURCES.attributes.java_classname}'
    env['JAVACLASSSUFFIX']  = '.class'
804475
public function generate() {
		$layout = $this->getTheme().'_layout';
		$layout = THEMES_ROOT.'/'.$this->getTheme()."/$layout.phtml";

		global $content;
		try {
			Router::start();

			$content = Router::getContent();

			if (!file_exists($layout)) { die("layout: $layout  not found"); }
		} catch (\Exception $exception) {
			$content = (new ExceptionGenerator($exception))->get();
		}

		if ($layout != 'no_layout') {
			require $layout;
		}
	}
38404
public function generateFiles()
    {
        foreach ($this->getFiles() as $stub => $file) {
            $path = $this->module->getModulePath($this->getName()) . $file;

            if (!$this->filesystem->isDirectory($dir = dirname($path))) {
                $this->filesystem->makeDirectory($dir, 0775, true);
            }

            $this->filesystem->put($path, $this->getStubContents($stub));
        }
    }
981798
public function generate($namespace, $bundle, $dir, $format, $structure, $dbDriver)
    {
        $dir .= '/'.strtr($namespace, '\\', '/');
        if (file_exists($dir)) {
            if (!is_dir($dir)) {
                throw new \RuntimeException(sprintf('Unable to generate the bundle as the target directory "%s" exists but is a file.', realpath($dir)));
            }
            $files = scandir($dir);
            if ($files != array('.', '..')) {
                throw new \RuntimeException(sprintf('Unable to generate the bundle as the target directory "%s" is not empty.', realpath($dir)));
            }
            if (!is_writable($dir)) {
                throw new \RuntimeException(sprintf('Unable to generate the bundle as the target directory "%s" is not writable.', realpath($dir)));
            }
        }

        $driverDir = array(
            'orm' => 'Entity',
            'mongodb' => 'Document',
            'couchdb' => 'CouchDocument',
            'custom' => 'Model',
        );

        $basename = substr($bundle, 0, -6);
        $parameters = array(
            'namespace' => $namespace,
            'bundle' => $bundle,
            'format' => $format,
            'db_driver' => $dbDriver,
            'model_namespace' => $namespace.'\\'.$driverDir[$dbDriver],
            'bundle_basename' => $basename,
            'extension_alias' => Container::underscore($basename),
        );

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

        $this->generateRoutes($namespace, $bundle, $dir, $format, $basename);
        $this->generateModels($namespace, $bundle, $dir, $dbDriver, $basename);
        $this->generateEventsClass($namespace, $bundle, $dir, $dbDriver, $basename);

        if ($structure) {
            $this->renderFile('bundle/messages.fr.xlf', $dir.'/Resources/translations/messages.fr.xlf', $parameters);

            $this->filesystem->mkdir($dir.'/Resources/doc');
            $this->filesystem->touch($dir.'/Resources/doc/index.rst');
            $this->filesystem->mkdir($dir.'/Resources/translations');
            $this->filesystem->mkdir($dir.'/Resources/public/css');
            $this->filesystem->mkdir($dir.'/Resources/public/images');
            $this->filesystem->mkdir($dir.'/Resources/public/js');
        }
    }
735197
public function generateFolders()
    {
        foreach ($this->getFolders() as $key => $folder) {
            $folder = GenerateConfigReader::read($key);

            if ($folder->generate() === false) {
                continue;
            }

            $path = $this->module->getModulePath($this->getName()) . '/' . $folder->getPath();

            $this->filesystem->makeDirectory($path, 0755, true);
            if (config('modules.stubs.gitkeep')) {
                $this->generateGitKeep($path);
            }
        }
    }
17823
protected function generateFiles()
    {
        foreach ($this->files as $key => $file) {
            $file = $this->formatContent($file);

            $this->makeFile($key, $file);
        }
    }
948905
public function generateFile()
    {
        parent::generateFile();

        if (count($this->uses) > 0) {
            sort($this->uses);
            $uses = '';
            foreach ($this->uses as $use) {
                $uses .= 'use ' . $use . ';' . $this->getNewlineCharacter();
            }
            $this->file_content = str_replace('{{ uses }}', $uses, $this->file_content);
        } else {
            $this->file_content = str_replace('{{ uses }}', '', $this->file_content);
        }
        $this->file_content = str_replace('{{ className }}', $this->class_name, $this->file_content);

        return $this->file_content;
    }
260121
protected function generateFileContents()
    {
        $data = $this->classTemplate;

        $data = str_replace("{EXTENDS}", $this->extends, $data);
        $data = str_replace("{NAMESPACE}", $this->namespace, $data);
        $data = str_replace("{CLASSNAME}", $this->classname, $data);
        $data = str_replace("{CONTENTS}", $this->contents, $data);
        $data = str_replace("{USES}", $this->uses, $data);

        return $data;
    }
843880
protected function generatePath()
    {
        $filesystem = new Filesystem();
        $path = $this->cacheFolder;
        $path = trim($path, '/');

        if (!empty($this->namespace)) {
            $path .= '/'.$this->namespace;
        }

        if (!$filesystem->exists($this->projectDir.'/'.$path)) {
            $filesystem->mkdir($this->projectDir.'/'.$path);
        }
        $this->cacheFolderWithNamespace = $path;
    }
982632
protected function _generateFiles() {
        $this->generateFilesForArtifacts($this->selectedArtifacts, "getFileSettingsForSelected", false);
        $this->generateFilesForArtifacts($this->deselectedArtifacts, "getFileSettingsForDeselected", false);
        
        $this->generateFilesForArtifacts($this->selectedArtifacts, "getFileSettingsForSelected", true);
        $this->generateFilesForArtifacts($this->deselectedArtifacts, "getFileSettingsForDeselected", true);

        foreach ($this->extendableFiles as $extendableFile)
            $this->files[] = $extendableFile;
    }
394338
def generate_files
      ip = local_ip
      version = Farmstead::VERSION
      scaffold_path = "#{File.dirname __FILE__}/scaffold"
      scaffold = Dir.glob("#{scaffold_path}/**/*.erb", File::FNM_DOTMATCH)
      scaffold.each do |file|
        basename = File.basename(file)
        folderstruct = file.match("#{scaffold_path}/(.*)")[1]
        if basename != folderstruct
          foldername = File.dirname(folderstruct)
          create_recursive("#{@name}/#{foldername}")
        end
        projectpath = "#{@name}/#{folderstruct}".chomp(".erb")
        template = File.read(file)
        results = ERB.new(template).result(binding)
        copy_to_directory(results, projectpath)
      end
    end
538219
protected function generateMapperFiles()
    {
        $dir = $this->baseDir . '/Mapper/' . str_replace('\\', '/', trim($this->config->getNamespace(), '\\ '));

        if (!is_dir($dir . '/Abstracts') && false === mkdir($dir . '/Abstracts', 0755, true)) {
            throw new \RuntimeException('Cannot create directory: ' . $dir);
        }

        $this->generateMapperFileAbstract($dir . '/Abstracts');
        $this->generateMapperFile($dir);
    }
460439
public function generate()
    {
        if (!is_dir($this->getInputDirectory())) {
            throw new \RuntimeException('The MakeDocs input directory does not exist.');
        }

        if (!$this->builders) {
            throw new \RuntimeException('No MakeDocs builders present.');
        }

        // First we change the working directory to the input, this makes rendering easier since
        // all paths are relative to source directory:
        $workingDirectory = getcwd();
        chdir($this->getInputDirectory());

        foreach ($this->builders as $builder) {
            $builder->build($this);
        }

        // Restore the working directory to its original form:
        chdir($workingDirectory);
    }
918490
public function generateFolders()
    {
        foreach ($this->getFolders() as $folder) {
            $path = $this->module->getModulePath($this->getName()).'/'.$folder;

            $this->filesystem->makeDirectory($path, 0755, true);

            $this->generateGitKeep($path);
        }
    }
488763
public function generate($namespace, $bundle, $dir, $format, $structure, $fields = null, $parent = null, $packagistParentName = null, $contentResolver = false, $parentContentResolver = false, $orgname = null, $cache = false)
    {
        $dir .= '/'.strtr($namespace, '\\', '/');
        if (file_exists($dir)) {
            if (!is_dir($dir)) {
                throw new \RuntimeException(sprintf('Unable to generate the bundle as the target directory "%s" exists but is a file.', realpath($dir)));
            }
            $files = scandir($dir);
            if ($files !== ['.', '..']) {
                throw new \RuntimeException(sprintf('Unable to generate the bundle as the target directory "%s" is not empty.', realpath($dir)));
            }
            if (!is_writable($dir)) {
                throw new \RuntimeException(sprintf('Unable to generate the bundle as the target directory "%s" is not writable.', realpath($dir)));
            }
        }

        $basename = substr($bundle, 0, -6);
        $widget = str_replace('VictoireWidget', '', $basename);
        $_fields = [];

        foreach ($fields as $_field) {
            $_fields[] = $_field['fieldName'];
        }

        //guess the toString property we could use
        $toStringProperty = 'id';
        if (in_array('name', $_fields)) {
            $toStringProperty = 'name';
        } elseif (in_array('title', $_fields)) {
            $toStringProperty = 'title';
        } elseif (in_array('description', $_fields)) {
            $toStringProperty = 'description';
        }

        $parameters = [
            'namespace'               => $namespace,
            'bundle'                  => $bundle,
            'parent'                  => $parent,
            'packagistParentName'     => $packagistParentName,
            'orgname'                 => $orgname,
            'widget'                  => $widget,
            'format'                  => $format,
            'fields'                  => $fields,
            'toStringProperty'        => $toStringProperty,
            'bundle_basename'         => $basename,
            'content_resolver'        => $contentResolver,
            'cache'                   => $cache,
            'parent_content_resolver' => $parentContentResolver,
            'extension_alias'         => Container::underscore($basename),
        ];

        $this->renderFile('bundle/Bundle.php.twig', $dir.'/'.$bundle.'.php', $parameters);
        $this->renderFile('README.md.twig', $dir.'/README.md', $parameters);
        $this->renderFile('composer.json.twig', $dir.'/composer.json', $parameters);
        $this->renderFile('bundle/Extension.php.twig', $dir.'/DependencyInjection/'.$basename.'Extension.php', array_merge($parameters, ['format' => 'yml']));
        $this->renderFile('bundle/Configuration.php.twig', $dir.'/DependencyInjection/Configuration.php', $parameters);

        $this->renderFile('widget/entity.php.twig', $dir.'/Entity/Widget'.$widget.'.php', $parameters);
        $this->renderFile('widget/form.php.twig', $dir.'/Form/Widget'.$widget.'Type.php', $parameters);

        $this->renderFile('widget/config.yml.twig', $dir.'/Resources/config/config.yml', $parameters);
        $this->renderFile('widget/services.yml.twig', $dir.'/Resources/config/services.yml', $parameters);

        $this->renderFile('widget/victoire.xliff.twig', $dir.'/Resources/translations/victoire.en.xliff', $parameters);
        $this->renderFile('widget/victoire.xliff.twig', $dir.'/Resources/translations/victoire.fr.xliff', $parameters);

        //Generate new and Edit views
        $this->renderFile('widget/views/new.html.twig.twig', $dir.'/Resources/views/new.html.twig', $parameters);
        $this->renderFile('widget/views/edit.html.twig.twig', $dir.'/Resources/views/edit.html.twig', $parameters);
        $this->renderFile('widget/views/show.html.twig.twig', $dir.'/Resources/views/show.html.twig', $parameters);

        if ($contentResolver) {
            $parameters['parentResolver'] = class_exists('Victoire\\Widget\\'.$parent.'Bundle\\Widget\\Resolver\\Widget'.$parent.'ContentResolver');
            $this->renderFile('widget/ContentResolver.php.twig', $dir.'/Resolver/Widget'.$widget.'ContentResolver.php', $parameters);
        }
    }
1202781
protected function buildGeneratorWrapper()
    {
        foreach ($this->generator as $key => &$value) {
            yield null;
            $this->currentKey   = $key;
            $this->currentValue =& $value;
        }
    }