1

I'm trying to write a custom vhost hook for Aegir3 and I need to get the site's docroot path. I can see that the info I want is being passed in the second variable ($data) but I can't figure out how to access it. It seems like there is an object $data['server'] that is of a custom Provision_Context_server class.

Can anyone provide an example or point me at some documentation on how to interact with that? I was hoping to be able to just use $data['server']['services']['http']['context']['site']['root'] but that doesn't seem to work.

EDIT: I managed to get to the data as follows, but it's an ugly hack:

  preg_match('/"root";s:\d*:"(.*?)"/', serialize($data), $aryMatches);
  $docRoot = $aryMatches[1];
  • I've added a new section to explain this on docs.aegirproject.org/en/3.x/extend/altering-behaviours/… – Herman van Rink Mar 27 '18 at 12:08
  • Thanks Herman, but do you have an example on how to use the data? IE, I don't want to just see the data that is getting sent, I need to use it in my hook function. Specifically, I'm looking for some way to access the root field. IE, would I use d($data)->root or the like? I need to get the DocRoot path for a custom entry in my vhost, but I can't figure a way to extract it out of $data short of serializing the variable and writing a regexp to pull it out of the text. – Charles Tassell Mar 28 '18 at 13:27
  • d()->root would probably be what you need. The drush_log command on the page mentioned above is the best way to see what data you've actually got. – Herman van Rink Mar 28 '18 at 18:10

Browse other questions tagged or ask your own question.