Commit bc4f781c authored by Jon Pugh's avatar Jon Pugh

Allow services to alter configuration file variables by adding a processConfiguration method.

parent 065e22ac
......@@ -232,7 +232,7 @@ class Configuration {
* 5. Render template with $this and $data and write out to filename().
* 6. If $mode and/or $group are set, apply them for the new file.
*/
function write() {
function write(Service $service) {
// Make directory structure if it does not exist.
$filename = $this->filename();
......@@ -249,6 +249,7 @@ class Configuration {
if ($filename && is_writeable(dirname($filename))) {
// manipulate data before passing to template.
$this->process();
$service->processConfiguration($this);
if ($template = $this->load_template()) {
// Make sure we can write to the file
......
......@@ -197,7 +197,7 @@ class Service implements BuilderAwareInterface
foreach ($this->getConfigurations()[$context->type] as $configuration_class) {
try {
$config = new $configuration_class($context, $this);
$config->write();
$config->write($this);
$context->getProvision()->getLogger()->info(
'Wrote {description} to {path}.', [
'description' => $config->description,
......
......@@ -8,6 +8,7 @@
namespace Aegir\Provision\Service\Http;
use Aegir\Provision\Configuration;
use Aegir\Provision\Context;
use Aegir\Provision\Robo\ProvisionExecutor;
use Aegir\Provision\Robo\ProvisionTasks;
......@@ -70,6 +71,18 @@ class HttpApacheDockerService extends HttpApacheService
$configs['site'][] = SiteConfiguration::class;
return $configs;
}
public function processConfiguration(Configuration &$config) {
// Replace platform's stored root with server's root.
$root_on_host = $this->context->getProperty('root');
$path_parts = explode(DIRECTORY_SEPARATOR, $root_on_host);
$directory = array_pop($path_parts);
$root_in_container = $this->provider->getProperty('aegir_root') . DIRECTORY_SEPARATOR . 'platforms' . DIRECTORY_SEPARATOR . $directory;
$config->data['root'] = $root_in_container;
}
public function verifyServer() {
$tasks = [];
......
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