Generate all the files that are needed to build a zend php extension.
506529
public function Start()
    {
        foreach($this->symbols->headers as $header_name=>$header_object)
        {
            // Skip disabled headers
            if(!$header_object->enabled)
            {
                $this->RemoveHeader($header_name);
                continue;
            }

            // Generate header file
            $header_content = $this->GenerateHeader($header_name);

            $this->AddHeader($header_name, $header_content);

            // Generate classes header file
            $classes_header_content = $this->GenerateClassesHeader($header_name);

            $this->AddHeader(
                $header_name,
                $classes_header_content,
                "includes/classes"
            );

            // Generate source file
            $source_content = $this->GenerateSource($header_name);

            $this->AddSource($header_name, $source_content);
        }

        $this->GenerateOtherSources();

        $this->GenerateCustomSources();

        $this->GenerateConfigs();
    }
72168
public function generate()
    {
        $name = $this->getName();

        if ($this->module->has($name)) {
            if ($this->force) {
                $this->module->delete($name);
            } else {
                $this->console->error("Module [{$name}] already exist!");

                return;
            }
        }

        $this->generateFolders();

        $this->generateFiles();

        if (!$this->plain) {
            $this->generateResources();
        }

        $this->console->info("Module [{$name}] created successfully.");
    }
1141523
protected function generateModule()
    {
        $location = $this->container['location'];
        $root     = module_path(null, '', $location);
        $manifest = config("modules.locations.$location.manifest") ?: 'module.json';
        $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider';

        if (!$this->files->isDirectory($root)) {
            $this->files->makeDirectory($root);
        }

        $mapping   = config("modules.locations.$location.mapping");
        $directory = module_path(null, $this->container['basename'], $location);
        $source    = __DIR__ . '/../../../resources/stubs/module';

        $this->files->makeDirectory($directory);

        $sourceFiles = $this->files->allFiles($source, true);

        if (!empty($mapping)) {
            $search = array_keys($mapping);
            $replace = array_values($mapping);
        }

        foreach ($sourceFiles as $file) {
            $contents = $this->replacePlaceholders($file->getContents());
            $subPath = $file->getRelativePathname();

            if (!empty($mapping)) {
                $subPath = str_replace($search, $replace, $subPath);
            }

            $filePath = $directory . '/' . $subPath;
            
            // if the file is module.json, replace it with the custom manifest file name
            if ($file->getFilename() === 'module.json' && $manifest) {
                $filePath = str_replace('module.json', $manifest, $filePath);
            }
            
            // if the file is ModuleServiceProvider.php, replace it with the custom provider file name
            if ($file->getFilename() === 'ModuleServiceProvider.php') {
                $filePath = str_replace('ModuleServiceProvider', $provider, $filePath);
            }
            
            $dir = dirname($filePath);
            
            if (! $this->files->isDirectory($dir)) {
                $this->files->makeDirectory($dir, 0755, true);
            }

            $this->files->put($filePath, $contents);
        }
    }
1157502
protected function _buildFiles()
    {
        $paths = $this->_paths;
        $paths[] = realpath(APP) . DIRECTORY_SEPARATOR;

        usort($paths, function ($a, $b) {
            return strlen($a) - strlen($b);
        });

        foreach ($this->_translations as $domain => $translations) {
            foreach ($translations as $msgid => $contexts) {
                foreach ($contexts as $context => $details) {
                    $plural = $details['msgid_plural'];
                    $files = $details['references'];
                    $occurrences = [];
                    foreach ($files as $file => $lines) {
                        $lines = array_unique($lines);
                        $occurrences[] = $file . ':' . implode(';', $lines);
                    }
                    $occurrences = implode("\n#: ", $occurrences);
                    $header = '';
                    if (!$this->param('no-location')) {
                        $header = '#: ' . str_replace(DIRECTORY_SEPARATOR, '/', str_replace($paths, '', $occurrences)) . "\n";
                    }

                    $sentence = '';
                    if ($context !== '') {
                        $sentence .= "msgctxt \"{$context}\"\n";
                    }
                    if ($plural === false) {
                        $sentence .= "msgid \"{$msgid}\"\n";
                        $sentence .= "msgstr \"\"\n\n";
                    } else {
                        $sentence .= "msgid \"{$msgid}\"\n";
                        $sentence .= "msgid_plural \"{$plural}\"\n";
                        $sentence .= "msgstr[0] \"\"\n";
                        $sentence .= "msgstr[1] \"\"\n\n";
                    }

                    if ($domain !== 'default' && $this->_merge) {
                        $this->_store('default', $header, $sentence);
                    } else {
                        $this->_store($domain, $header, $sentence);
                    }
                }
            }
        }
    }
956272
public function build()
    {
        $tokenParsers = [];
        $executionStrategies = [];
        $functions = [];

        foreach ($this->extensions as $extension) {
            $tokenParsers = array_merge($tokenParsers, $extension->getTokenParsers());
            $executionStrategies = array_merge($executionStrategies, $extension->getExecutionStrategies());
            $functions = array_merge($functions, $extension->getFunctions());
        }

        $registry = new Registry($tokenParsers, [], [], '<{', '}>');

        $this->syntax = new Syntax(new Lexer(new TemplateLexer($registry)), new Parser(new TemplateParser($registry)));

        $this->executionStrategies = new ExecutionStrategyCollection($executionStrategies);

        $this->environment = new Environment($functions);

        $this->isLocked = true;
    }
502039
def generate(self):
        """"""
        for root, _, files in os.walk(self.source_dir):
            for fname in files:
                source_fpath = os.path.join(root, fname)
                self.generate_api_for_source(source_fpath)
283745
protected function _generateFiles() {
        foreach ($this->selectedArtifacts as $artifact) {
            $settings = $artifact->getGeneratorSettings(static::getKey());

            foreach ($this->getFileOrDirectorySettings($settings, "files") as $file)
                $this->_processFileSpecification(
                    $artifact, fphp\Specification\FileSpecification::fromArrayAndSettings($file, $settings));

            foreach ($this->getFileOrDirectorySettings($settings, "directories") as $directory) {
                $directorySpecification = fphp\Specification\DirectorySpecification::fromArrayAndSettings($directory, $settings);
                
                foreach ($directorySpecification->getFileSpecifications() as $fileSpecification)
                    $this->_processFileSpecification($artifact, $fileSpecification);
            }
        }
    }
491376
public function compileProxies()
    {
        Files::emptyDirectoryRecursively(Files::concatenatePaths([$this->environment->getPathToTemporaryDirectory(), 'Doctrine/Proxies']));
        /** @var \Doctrine\ORM\Proxy\ProxyFactory $proxyFactory */
        $proxyFactory = $this->entityManager->getProxyFactory();
        $proxyFactory->generateProxyClasses($this->entityManager->getMetadataFactory()->getAllMetadata());
    }
832764
public function generate()
    {
        $version = date('YmdHis');

        $this->_generateMigrationFile($version);
        print PHP_EOL . Color::success('Version ' . $version . ' was successfully generated') . PHP_EOL;
    }
1004623
public function actionCompile()
    {
        
        $extensionsToCreate = explode(',', $this->options['extension']);
        $extensionsToCreate = array_unique($extensionsToCreate);
        
		foreach ($extensionsToCreate as $extension){
			$language = $this->options['language'];
			$compiledTranslationFile = new tao_helpers_translation_TranslationFile();
			$compiledTranslationFile->setTargetLanguage($this->options['language']);
			
			$this->outVerbose("Compiling language '${language}' for extension '${extension}'...");
			
			// Get the dependencies of the target extension.
			// @todo Deal with dependencies at compilation time.
			$dependencies = array();
			if ($extension !== 'tao'){
				$dependencies[] = 'tao';
			}
			
			$this->outVerbose("Resolving Dependencies...");
			foreach ($dependencies as $depExtId){
				$this->outVerbose("Adding messages from extension '${depExtId}' in '${language}'...");
				// Does the locale exist for $depExtId?
				$depPath = $this->buildLanguagePath($depExtId, $language) . '/' . self::DEF_PO_FILENAME;
				if (!file_exists($depPath) || !is_readable($depPath)){
					$this->outVerbose("Dependency on extension '${depExtId}' in '${language}' does not exist. Trying to resolve default language...");
					$depPath = $this->buildLanguagePath($depExtId, tao_helpers_translation_Utils::getDefaultLanguage() . '/' . self::DEF_PO_FILENAME);

					if (!file_exists($depPath) || !is_readable($depPath)){
						$this->outVerbose("Dependency on extension '${depExtId}' in '${language}' does not exist.");
						continue;
					}
				}
				
				// Recompile the dependent extension (for the moment 'tao' meta-extension only).
				$oldVerbose = $this->options['verbose'];
				$this->parameters['verbose'] = false;
				$this->options['extension'] = $depExtId;
				$this->actionCompile();
				$this->options['extension'] = $extension;
				$this->parameters['verbose'] = $oldVerbose;
				
				$poFileReader = new tao_helpers_translation_POFileReader($depPath);
				$poFileReader->read();
				$poFile = $poFileReader->getTranslationFile();
				$poCount = $poFile->count();
				$compiledTranslationFile->addTranslationUnits($poFile->getTranslationUnits());
				
				$this->outVerbose("${poCount} messages added.");
			}

			if (($extDirectories = scandir(ROOT_PATH)) !== false){
						
				// Get all public messages accross extensions.
				foreach ($extDirectories as $extDir){
					$extPath = ROOT_PATH . '/' . $extDir;
					
					if (is_dir($extPath) && is_readable($extPath) && $extDir[0] != '.' && !in_array($extDir, $dependencies) && $extDir != $extension && $extDir != 'generis'){
						$this->outVerbose("Adding public messages from extension '${extDir}' in '${language}'...");
						
						$poPath = $this->buildLanguagePath($extDir, $language) . '/' . self::DEF_PO_FILENAME;
						if (!file_exists($poPath) || !is_readable($poPath)){
							$this->outVerbose("Extension '${extDir}' is not translated in language '${language}'. Trying to retrieve default language...");
							$poPath = $this->buildLanguagePath($extDir, tao_helpers_translation_Utils::getDefaultLanguage()) . '/' . self::DEF_PO_FILENAME;
							
							if (!file_exists($poPath) || !is_readable($poPath)){
								$this->outVerbose("Extension '${extDir}' in '${language}' does not exist.");
								continue;
							}
						}

						$poFileReader = new tao_helpers_translation_POFileReader($poPath);
						$poFileReader->read();
						$poFile = $poFileReader->getTranslationFile();
						$poUnits = $poFile->getByFlag('tao-public');
						$poCount = count($poUnits);
						$compiledTranslationFile->addTranslationUnits($poUnits);
						$this->outVerbose("${poCount} public messages added.");
					}
				}                
				
				// Finally, add the translation units related to the target extension.
				$path = $this->buildLanguagePath($extension, $language) . '/' . self::DEF_PO_FILENAME;
				if (file_exists($path) && is_readable($path)){
					$poFileReader = new tao_helpers_translation_POFileReader($path);
					$poFileReader->read();
					$poFile = $poFileReader->getTranslationFile();
					$compiledTranslationFile->addTranslationUnits($poFile->getTranslationUnits());
					
					// Sort the TranslationUnits.
					$sortingMethod = tao_helpers_translation_TranslationFile::SORT_ASC_I;
					$compiledTranslationFile->setTranslationUnits($compiledTranslationFile->sortBySource($sortingMethod));
					
					$jsPath = $this->buildLanguagePath($extension, $language) . '/' . self::DEF_JS_FILENAME;
					$jsFileWriter = new tao_helpers_translation_JSFileWriter($jsPath, $compiledTranslationFile);
					$jsFileWriter->write();
					$this->outVerbose("JavaScript compiled translations for extension '${extension}' with '${language}' written.");
				}
				else{
					$this->err("PO file '${path}' for extension '${extension}' with language '${language}' cannot be read.", true);
				}
			}
			else{
				$this->err("Cannot list TAO Extensions from root path. Check your system rights.", true);    
			}

			$this->outVerbose("Translations for '${extension}' with language '${language}' gracefully compiled.");

		}
        
    }
374576
public function generateModels()
    {
        $sourceRoot = $this->source . '/Model';

        $destinationRoot = $this->cwd
            . $this->schema['paths']['model']
            . '/' . ucwords($this->schema['name']);

        if(!is_dir($destinationRoot)) {
            mkdir($destinationRoot, 0777, true);
        }

        foreach($this->schema['model'] as $action) {
            $source = $sourceRoot . '/' . ucwords($action) . '.html';

            $destination = $destinationRoot . '/' . ucwords($action) . '.php';

            if(!file_exists($source)) {
                Index::error(sprintf(
                    self::SKIP,
                    'Model',
                    ucwords($action)),
                false);

                continue;
            }

            $this->copy($source, $destination);
        }
    }
909992
public function generateFiles() {
        if ($this->files === null) {
            $this->files = array();
            $this->tracingLinks = array();
            $this->_generateFiles();
        }
        if ($this->settings->getOptional("logFile", false))
            return array_merge(array($this->logFile), $this->files);
        else
            return $this->files;
    }
1124648
public function actionCreate()
    {
        
        $extensionsToCreate = explode(',', $this->options['extension']);
        $extensionsToCreate = array_unique($extensionsToCreate);
        
        foreach ($extensionsToCreate as $etc){
        	$this->options['extension'] = $etc;
        	$this->options['input'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_INPUT_DIR;
        	$this->options['output'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_OUTPUT_DIR;
        	
        	$this->outVerbose("Creating language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' ...");
        	 
        	// We first create the directory where locale files will go.
        	$dir = $this->buildLanguagePath($this->options['extension'], $this->options['language']);
        	$dirExists = false;
        	
        	if (file_exists($dir) && is_dir($dir) && $this->options['force'] == true) {
        		$dirExists = true;
        		$this->outVerbose("Language '" . $this->options['language'] . "' exists for extension '" . $this->options['extension'] . "'. Creation will be forced.");
        		 
        		// Clean it up.
        		foreach (scandir($dir) as $d) {
        			if ($d !== '.' && $d !== '..' && $d !== '.svn') {
        				if (!tao_helpers_File::remove($dir . '/' . $d, true)) {
        					$this->err("Unable to clean up 'language' directory '" . $dir . "'.", true);
        				}
        			}
        		}
        	} else if (file_exists($dir) && is_dir($dir) && $this->options['force'] == false) {
        		$this->err("The 'language' " . $this->options['language'] . " already exists in the file system. Use the 'force' parameter to overwrite it.", true);
        	}
        	
        	// If we are still here... it means that we have to create the language directory.
        	if (!$dirExists && !@mkdir($dir)) {
        		$this->err("Unable to create 'language' directory '" . $this->options['language'] . "'.", true);
        	} else {
        		if ($this->options['build'] == true) {
        			$sortingMethod = tao_helpers_translation_TranslationFile::SORT_ASC_I;
        			$this->outVerbose("Building language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' ...");
        			// Let's populate the language with raw PO files containing sources but no targets.
        			// Source code extraction.
        			$fileExtensions = array('php', 'tpl', 'js', 'ejs');
        			$filePaths = array();
        			foreach (self::$WHITE_LIST as $subFolder) {
        			    $filePaths[] = $this->options['input'] . DIRECTORY_SEPARATOR. $subFolder;
        			}
        			 
        			$sourceExtractor = new tao_helpers_translation_SourceCodeExtractor($filePaths, $fileExtensions);
        			$sourceExtractor->extract();
        	
        			$translationFile = new tao_helpers_translation_POFile();
        			$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
        			$translationFile->setTargetLanguage($this->options['language']);
        			$translationFile->addTranslationUnits($sourceExtractor->getTranslationUnits());
        			
        			$file = MenuService::getStructuresFilePath($this->options['extension']);
        			if (!is_null($file)) {
            			$structureExtractor = new tao_helpers_translation_StructureExtractor(array($file));
            			$structureExtractor->extract();
            			$translationFile->addTranslationUnits($structureExtractor->getTranslationUnits());
        			}

        			$sortedTus = $translationFile->sortBySource($sortingMethod);
        	
        			$sortedTranslationFile = new tao_helpers_translation_POFile();
        			$sortedTranslationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
        			$sortedTranslationFile->setTargetLanguage($this->options['language']);
        			$sortedTranslationFile->addTranslationUnits($sortedTus);
        			$this->preparePOFile($sortedTranslationFile, true);

        			$poPath = $dir . '/' . self::DEF_PO_FILENAME;
        			$writer = new tao_helpers_translation_POFileWriter($poPath,
        					$sortedTranslationFile);
        			$writer->write();
        			$this->outVerbose("PO Translation file '" . basename($poPath) . "' in '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] ."'.");
        			$writer->write();

					// Writing JS files
					$jsPath = $dir . '/' . self::DEF_JS_FILENAME;
        			$writer = new tao_helpers_translation_JSFileWriter(
						 $jsPath, $sortedTranslationFile
					);
        			$writer->write(false);
					$this->outVerbose("JavaScript Translation file '" . basename($jsPath) . "' in '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] ."'.");
					$writer->write();

        			// Now that PO files & JS files are created, we can create the translation models
        			// if we find RDF models to load for this extension.
        			$translatableProperties = array(OntologyRdfs::RDFS_LABEL, OntologyRdfs::RDFS_COMMENT);
        	
        			foreach ($this->getOntologyFiles() as $f){
       					common_Logger::d('reading rdf '.$f);
						$translationFile = $this->extractPoFileFromRDF($f, $translatableProperties);

						$writer = new tao_helpers_translation_POFileWriter($dir . '/' . $this->getOntologyPOFileName($f), $translationFile);
       					$writer->write();

       					$this->outVerbose("PO Translation file '" .  $this->getOntologyPOFileName($f) . "' in '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] . "'.");
        			}
        	
        			$this->outVerbose("Language '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] . "'.");
        		} else {
        			// Only build virgin files.
        			// (Like a virgin... woot !)
        			$translationFile = new tao_helpers_translation_POFile();
        			$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
        			$translationFile->setTargetLanguage($this->options['language']);
        			$this->preparePOFile($translationFile, true);

        			foreach ($this->getOntologyFiles() as $f){
                            common_Logger::d('reading rdf '.$f);
                            $translationFile = new tao_helpers_translation_POFile();
        					$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
        					$translationFile->setTargetLanguage($this->options['language']);
        					$translationFile->setExtensionId($this->options['extension']);

						$writer = new tao_helpers_translation_POFileWriter($dir . '/' . $this->getOntologyPOFileName($f), $translationFile);
                        $writer->write();
        			}
        	
        			$this->outVerbose("Language '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] . "'.");
        		}
        	
        		// Create the language manifest in RDF.
        		if ($this->options['extension'] == 'tao'){
        			$langDescription = tao_helpers_translation_RDFUtils::createLanguageDescription($this->options['language'],
        					$this->options['languageLabel']);
        			$langDescription->save($dir . '/' . self::DEF_LANG_FILENAME);
        		}
        	}	
        }
        
    }
291300
public function GenerateOtherSources()
    {
        // Variables used by some template files.
        $authors = \Peg\Lib\Settings::GetAuthors();
        $contributors = \Peg\Lib\Settings::GetContributors();
        $extension = \Peg\Lib\Settings::GetExtensionName();
        $version = \Peg\Lib\Settings::GetVersion();

        // Variable to temporarily store a template file content.
        $content = "";
        
        // Generate common.h
        ob_start();
            include($this->GetGenericTemplate("common.h", "sources"));
            $content = ob_get_contents();
        ob_end_clean();

        $this->AddGenericFile("common.h", $content, "includes");

        // Generate all_headers.h
        $headers = "";
        foreach($this->symbols->headers as $header_name=>$header_object)
        {
            if($header_object->enabled)
            {
                $headers .= '#include "'
                    . $this->GetHeaderNamePHP($header_name)
                    . '"'
                    . "\n"
                ;
            }
        }

        ob_start();
            include($this->GetGenericTemplate("all_headers.h", "sources"));
            $content = ob_get_contents();
        ob_end_clean();

        $this->AddGenericFile("all_headers.h", $content, "includes");

        // Generate functions.h/cpp
        ob_start();
            include($this->GetGenericTemplate("functions.h", "sources"));
            $content = ob_get_contents();
        ob_end_clean();

        $this->AddGenericFile("functions.h", $content, "includes");

        ob_start();
            include($this->GetGenericTemplate("functions.cpp", "sources"));
            $content = ob_get_contents();
        ob_end_clean();

        $this->AddGenericFile("functions.cpp", $content, "src");

        // Generate references.h/cpp
        ob_start();
            include($this->GetGenericTemplate("references.h", "sources"));
            $content = ob_get_contents();
        ob_end_clean();

        $this->AddGenericFile("references.h", $content, "includes");

        ob_start();
            include($this->GetGenericTemplate("references.cpp", "sources"));
            $content = ob_get_contents();
        ob_end_clean();

        $this->AddGenericFile("references.cpp", $content, "src");

        // Generate php_extension.h/c
        $constants_register = "";
        $enums_register = "";
        $functions_register = "";
        $classes_register = "";

        foreach($this->symbols->headers as $header_name=>$header_object)
        {
            $header_define = $this->GetHeaderDefine($header_name);

            if($header_object->enabled)
            {
                if($header_object->HasConstants())
                {
                    ob_start();
                        include($this->GetTemplatePath(
                            $header_name,
                            "constants",
                            "function_call",
                            "helpers",
                            "constant"
                        ));
                        $constants_register .= ob_get_contents();
                    ob_end_clean();
                }

                if($header_object->HasEnumerations())
                {
                    ob_start();
                        include($this->GetTemplatePath(
                            $header_name,
                            "enums",
                            "function_call",
                            "helpers",
                            "enum"
                        ));
                        $enums_register .= ob_get_contents();
                    ob_end_clean();
                }

                if($header_object->HasEnumerations())
                {
                    ob_start();
                        include($this->GetTemplatePath(
                            $header_name,
                            "functions",
                            "function_call",
                            "helpers",
                            "function"
                        ));
                        $functions_register .= ob_get_contents();
                    ob_end_clean();
                }

                if($header_object->HasClasses())
                {
                    foreach($header_object->namespaces as $namespace_name=>$namespace_object)
                    {
                        if($namespace_name == "\\")
                            $namespace_name = "";

                        $namespace_name_cpp = str_replace(
                            "\\",
                            "::",
                            $namespace_name
                        );

                        $namespace_name_var = str_replace(
                            "\\",
                            "_",
                            $namespace_name
                        );

                        foreach($namespace_object->classes as $class_name=>$class_object)
                        {
                            ob_start();
                                include($this->GetTemplatePath(
                                    $class_name,
                                    "classes",
                                    "function_call",
                                    "helpers",
                                    "class"
                                ));
                                $classes_register .= ob_get_contents();
                            ob_end_clean();
                        }
                    }
                }
            }
        }

        $constants_register = $this->Indent($constants_register, 8);
        $enums_register = $this->Indent($enums_register, 8);
        $functions_register = $this->Indent($functions_register, 8);
        $classes_register = $this->Indent($classes_register, 4);

        ob_start();
            include($this->GetGenericTemplate("php_extension.h", "sources"));
            $content = ob_get_contents();
        ob_end_clean();

        $this->AddGenericFile("php_" . strtolower($extension) . ".h", $content);

        ob_start();
            include($this->GetGenericTemplate("extension.c", "sources"));
            $content = ob_get_contents();
        ob_end_clean();

        $this->AddGenericFile(strtolower($extension) . ".c", $content);

        // Generate object_types.h
        $object_types = "";
        foreach($this->symbols->headers as $header_name=>$header_object)
        {
            foreach($header_object->namespaces as $namespace_name=>$namespace_object)
            {
                if($namespace_name == "\\")
                    $namespace_name = "";

                $namespace_name_var = strtoupper(
                        str_replace(
                        "\\",
                        "_",
                        $namespace_name
                    )
                );

                foreach($namespace_object->classes as $class_name=>$class_object)
                {
                    if($namespace_name)
                    {
                        $object_types .= "PHP_"
                            . $namespace_name_var . "_"
                            . strtoupper($class_name)
                            . "_TYPE,"
                            . "\n    "
                        ;
                    }
                    else
                    {
                        $object_types .= "PHP_"
                            . strtoupper($class_name)
                            . "_TYPE,"
                            . "\n    "
                        ;
                    }
                }
            }
        }

        $object_types = rtrim($object_types, "\n, ") . "\n";

        ob_start();
            include($this->GetGenericTemplate("object_types.h", "sources"));
            $content = ob_get_contents();
        ob_end_clean();

        $this->AddGenericFile("object_types.h", $content, "includes");
    }
1114085
public static function build()
    {
        $ini = eZINI::instance( 'file.ini' );
        $defaultHandler = eZDFSFileHandlerBackendFactory::buildHandler(
            $ini->variable( 'DispatchableDFS', 'DefaultBackend' )
        );

        $pathHandlers = array();
        foreach ( $ini->variable( 'DispatchableDFS', 'PathBackends' ) as $supportedPath => $backendClass )
        {
            // @todo Make it possible to use a Symfony2 service
            $pathHandlers[$supportedPath] = eZDFSFileHandlerBackendFactory::buildHandler( $backendClass );
        }

        return new static( $defaultHandler, $pathHandlers );
    }
205511
private function createDatagridFiles() {
        $db = \Cityware\Db\Factory::factory('zend');
        $tableMetadata = new \Zend\Db\Metadata\Metadata($db->getAdapter());
        $tableInfo = $tableMetadata->getTable($this->getTable(), $this->getSchema());

        $iniFile = $this->genConfigDatagridIni();
        $iniFile .= $this->genFieldsDatagridIni($tableInfo);

        $translateFile = $this->genTranslateDatagridArray($tableInfo);

        $moduleName = ucfirst($this->getModule());
        $moduleNameLower = strtolower($this->getModule());

        try {
            if (!empty($this->datagridName)) {
                file_put_contents($this->dstIniDirectory . $this->datagridName . '.ini', $iniFile);
                chmod($this->dstIniDirectory . $this->datagridName . '.ini', 0777);

                file_put_contents($this->dstTranslateDirectory . $this->datagridName . '.php', $translateFile);
                chmod($this->dstTranslateDirectory . $this->datagridName . '.php', 0777);

                $datagrid_template_phtml = file_get_contents($this->srcTemplateDirectory . 'Template_Datagrid_Index.tmpl');
                $datagridTemplatePhtml = str_replace("%moduleName%", $moduleName, str_replace("%moduleNameLower%", $moduleNameLower, $datagrid_template_phtml));
                file_put_contents($this->dstViewDirectory . $this->datagridName . '.phtml', $datagridTemplatePhtml);
                chmod($this->dstViewDirectory . $this->datagridName . '.phtml', 0644);
            } else {
                file_put_contents($this->dstIniDirectory . 'datagrid.ini', $iniFile);
                chmod($this->dstIniDirectory . 'datagrid.ini', 0777);

                file_put_contents($this->dstTranslateDirectory . 'datagrid.php', $translateFile);
                chmod($this->dstTranslateDirectory . 'datagrid.php', 0777);

                $datagrid_template_phtml = file_get_contents($this->srcTemplateDirectory . 'Template_Datagrid_Index.tmpl');
                $datagridTemplatePhtml = str_replace("%moduleName%", $moduleName, str_replace("%moduleNameLower%", $moduleNameLower, $datagrid_template_phtml));
                file_put_contents($this->dstViewDirectory . 'index.phtml', $datagridTemplatePhtml);
                chmod($this->dstViewDirectory . 'index.phtml', 0644);

                $datagrid_template_trash = file_get_contents($this->srcTemplateDirectory . 'Template_Datagrid_Trash.tmpl');
                $datagridTemplateTrash = str_replace("%moduleName%", $moduleName, str_replace("%moduleNameLower%", $moduleNameLower, $datagrid_template_trash));
                file_put_contents($this->dstViewDirectory . 'trash.phtml', $datagridTemplateTrash);
                chmod($this->dstViewDirectory . 'trash.phtml', 0644);
            }
        } catch (Exception $exc) {
            throw new Exception('Não foi possivel criar o arquivo de configuração do Datagrid! <br />' . $exc->getMessage(), 500);
        }
    }
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);
        }
    }