Commit b441a70e authored by Christopher Gervais's avatar Christopher Gervais Committed by Dan Friedman
Browse files

Generate service.yml file to set cookie domains, and thus fix link construction on subdir sites.

parent 648753f0
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
<?php
/**
 * @file
 * Provides the Provision_Config_Drupal_Services class.
 */

class Provision_Config_Drupal_Services extends Provision_Config {
  public $template = 'aegir.services.tpl.php';
  public $description = 'Drupal aegir.services.yml file';
  protected $mode = 0440;

  function filename() {
    return $this->site_path . '/aegir.services.yml';
  }

  function process() {
    $this->version = provision_version();
    $this->cookie_domain = $this->getCookieDomain();
    $this->group = $this->platform->server->web_group;
  }

  /**
   * Extract our cookie domain from the URI.
   */
  protected function getCookieDomain() {
    $uri = explode('.', $this->uri);
    # Leave base domain; only strip out subdomains.
    if (count($uri) > 2) {
      $uri[0] = '';
    }
    return implode('.', $uri);
  }

}
+9 −0
Original line number Diff line number Diff line
---

# This file was automatically generated by Aegir <?php print $this->version; ?>

# on <?php print date('r'); ?>.

parameters:
  session.storage.options:
    cookie_domain: '<?php print $this->cookie_domain; ?>'
+1 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ if (isset($_SERVER['db_name'])) {
  /**
   * Load services definition file.
   */
  $settings['container_yamls'][] = __DIR__ . '/aegir.services.yml';
  $settings['container_yamls'][] = __DIR__ . '/services.yml';

  /**
+6 −2
Original line number Diff line number Diff line
@@ -168,8 +168,12 @@ function provision_drupal_fetch_site($alias = NULL) {
 * Generate a settings file for the site.
 */
function _provision_drupal_create_settings_file() {
  $config = new Provision_Config_Drupal_Settings(d()->name, drush_get_context('site'));
  $config->write();
  $name = d()->name;
  $context = drush_get_context('site');
  $settings = new Provision_Config_Drupal_Settings($name, $context);
  $settings->write();
  $services = new Provision_Config_Drupal_Services($name, $context);
  $services->write();
}

/**