#!/usr/bin/php $value) { $updated = str_replace('KEY', $key, $template); $updated = str_replace('VALUE', $value, $updated); $newOptions .= $updated; } $contents = file_get_contents($file); $contents = preg_replace( '/\/\/\bOPTIONS_INIT_START\b.*?\/\/\bOPTIONS_INIT_END\b/s', "//OPTIONS_INIT_START\n" . $newOptions . "\t\t//OPTIONS_INIT_END", $contents ); file_put_contents($file, $contents); /** * Process createInstance options */ $template = file_get_contents('src/templates/create_instance_options.template'); $newOptions = []; foreach ($options as $key => $value) { if (in_array($key, $excludeOptions)) { continue; } if (array_key_exists($key, $instanceMappings)) { $value = $instanceMappings[$key]; } else { $value = $key; } $updated = str_replace('INSTANCE_KEY', $value, $template); $updated = str_replace('KEY', $key, $updated); array_push($newOptions, $updated); } if (sizeof($newOptions) > 0) { $contents = file_get_contents($file); $contents = preg_replace( '/\/\/\bCREATE_INSTANCE_OPTIONS_START\b.*?\/\/\bCREATE_INSTANCE_OPTIONS_END\b/s', "//CREATE_INSTANCE_OPTIONS_START\n" . implode(",\n", $newOptions) . "\n\t\t\t\t//CREATE_INSTANCE_OPTIONS_END", $contents ); file_put_contents($file, $contents); } /** * Process updateInstance options */ $template = file_get_contents('src/templates/update_instance_options.template'); $newOptions = ''; foreach ($options as $key => $value) { if (in_array($key, $excludeOptions)) { continue; } if (array_key_exists($key, $instanceMappings)) { $value = $instanceMappings[$key]; } else { $value = $key; } $updated = str_replace('INSTANCE_KEY', $value, $template); $updated = str_replace('KEY', $key, $updated); $newOptions .= $updated; } $contents = file_get_contents($file); $contents = preg_replace( '/\/\/\bUPDATE_INSTANCE_OPTIONS_START\b.*?\/\/\bUPDATE_INSTANCE_OPTIONS_END\b/s', "//UPDATE_INSTANCE_OPTIONS_START\n" . $newOptions. "\t\t//UPDATE_INSTANCE_OPTIONS_END", $contents ); file_put_contents($file, $contents); /** * Process updateFromInstance options */ $template = file_get_contents('src/templates/update_from_instance_options.template'); $newOptions = ''; foreach ($options as $key => $value) { if (in_array($key, $excludeOptions)) { continue; } if (array_key_exists($key, $instanceMappings)) { $value = $instanceMappings[$key]; } else { $value = $key; } $updated = str_replace('INSTANCE_KEY', $value, $template); $updated = str_replace('KEY', $key, $updated); $newOptions .= $updated; } $contents = file_get_contents($file); $contents = preg_replace( '/\/\/\bUPDATE_FROM_INSTANCE_OPTIONS_START\b.*?\/\/\bUPDATE_FROM_INSTANCE_OPTIONS_END\b/s', "//UPDATE_FROM_INSTANCE_OPTIONS_START\n" . $newOptions. "\t\t//UPDATE_FROM_INSTANCE_OPTIONS_END", $contents ); file_put_contents($file, $contents); } exit(0); ?>