/** * Merge the new style extensions * @param string $module_path Path to the module's directory. */ public function mergeExtensionFiles($module_path) { $php_tags = array('<?php', '?>', '<?PHP', '<?'); $path = "custom/Extension/{$module_path}/Ext/clients"; $clients = MetaDataFiles::getClients(); foreach ($clients as $client) { foreach (glob("{$path}/{$client}/*", GLOB_ONLYDIR | GLOB_NOSORT) as $layout) { $layoutType = basename($layout); foreach (glob("{$layout}/*", GLOB_ONLYDIR | GLOB_NOSORT) as $subLayout) { $subLayoutFileName = basename($subLayout); $extension = "<?php\n// WARNING: The contents of this file are auto-generated.\n"; $override = array(); foreach (glob("{$subLayout}/*.php") as $file) { $basenameFile = basename($file); if (substr($basenameFile, 0, 9) == '_override') { $override[] = $file; } else { $fileContents = file_get_contents($file); $extension .= "\n" . str_replace($php_tags, '', $fileContents); } } foreach ($override as $file) { $fileContents = file_get_contents($file); $extension .= "\n" . str_replace($php_tags, '', $fileContents); } $cachePath = "custom/{$module_path}/Ext/clients/{$client}/{$layoutType}/{$subLayoutFileName}"; if (!is_dir($cachePath)) { sugar_mkdir($cachePath, null, true); } SugarAutoLoader::put("{$cachePath}/{$subLayoutFileName}.ext.php", $extension, true); } } } }