I am trying to use hook_provision_provision_apache_vhost_config()
to write more server variables to my apache/nginx configs.
The problem is that I don't have access to all of the available information in the site context.
I have fixed this by adding $this to the hook invocation.
So now, Provision/Config/Apache/Site.php looks like this:
/**
* Apache site level config class. Virtual host.
*/
class Provision_Config_Apache_Site extends Provision_Config_Http_Site {
function process() {
parent::process();
$this->data['extra_config'] = "# Extra configuration from modules:\n";
$this->data['extra_config'] .= join("\n", drush_command_invoke_all('provision_apache_vhost_config', $this->uri, $this->data, $this));
}
}
We could remove the $this->uri and $this->data, but this would break backwards compatibility with any existing hook implementations.
This is a problem for a lot of hooks actually...
- hook_provision_drupal_config
- drush_hook_provision_apache_server_config
- drush_hook_provision_apache_dir_config
- drush_hook_provision_apache_vhost_config
- drush_hook_provision_nginx_server_config
- drush_hook_provision_nginx_dir_config
- drush_hook_provision_nginx_vhost_config
I propose that in the current release branch we add $this as an additional parameter to all of the hook invocations so we don't break backwards compatibiltiy, and we revisit this in future releases.
I am going to push a branch soon with these proposed changes.
Thoughts?
Thanks!
Comments
Comment #2
Jon PughNew code available in branches
6.x-2.x-provision-hooks-2562467
and7.x-3.x-provision-hooks-2562467
Comment #4
Jon PughOk, I am now realizing that the d() function is available inside these hooks, but it's not documented.
Not sure what the best approach here is.
Do we:
Comment #5
ergonlogicd()
is pretty much always available, but carries an awful lot of complex data around with it. The$uri
and$data
parameters simplify access to the most common data we're likely to use within these hooks. This is similar to how$form_id
is provided inhook_form_alter()
, despite the fact that it could be pulled out of$form
.Feel free to add an example of
d()
within the API docs for these hooks. Otherwise, I think this could beClosed (works as designed)
.Comment #7
Jon PughGood call. I've added the mention to the doc blocks and deleted the branches I created.
Thanks!
Comment #9
gboudrias CreditAttribution: gboudrias at Praxis Labs Coop commented