Commit baaa6916 authored by helmo's avatar helmo

Issue #2853184 by Jon Pugh: Merge remote-tracking branch...

Issue #2853184 by Jon Pugh: Merge remote-tracking branch 'origin/2853184-template-vars-alter' into 7.x-3.x
parents 25259afc 71a4de73
......@@ -167,6 +167,11 @@ 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 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, $template, $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