Commit bcd19f36 authored by Jon Pugh's avatar Jon Pugh

Issue #2853184: In the Provision_Config::render_template() method, add...

Issue #2853184: In the Provision_Config::render_template() method, add drush_command_invoke_all_ref() to create hook_provision_config_variables_alter(), allowing drush files to alter variables right before they are written to templates.
parent 874d0945
......@@ -167,6 +167,10 @@ class Provision_Config {
* array.
*/
private function render_template($template, $variables) {
// Allow modules to alter the variables before writing to the template.
// @see hook_provision_config_variables_alter()
drush_command_invoke_all_ref('provision_config_variables_alter', $variables, $template, $this);
drush_errors_off();
extract($variables, EXTR_SKIP); // Extract the variables to a local namespace
ob_start(); // Start output buffering
......
......@@ -215,6 +215,31 @@ function hook_provision_config_load_templates_alter(&$templates, $config) {
$templates = array();
}
/**
* Alter the template and variables used for rendering a config file.
*
* When implementing this hook, the function name should start with your file's name, not "drush_".
*
* @param $variables
* The variables that are about to be injected into the template.
* @param $template
* The template file chosen for use
* @param $config
* The Provision_config object trying to find its template.
*
* @see hook_provision_config_load_templates()
* @see hook_provision_config_load_templates_alter()
*/
function hook_provision_config_variables_alter(&$variables, $templates, $config) {
// If this is the vhost template and the http service is Docker...
if (is_a($config, 'Provision_Config_Apache_Site') && is_a(d()->platform->service('http'), 'Provision_Service_http_apache_docker')) {
// Force the listen port to be 80.
$variables['http_port'] = '80';
}
}
/**
* Alter the array of directories to create.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment