Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [33mfd37a2b[m I added the _elc_domain_get_domain_aliases() function to the elc_domain/includes/bootstrap.inc file. This function allows the settings.ENV.php files to load a subset of domains to be used as aliases for a master domain. This master domain record is stored in the {domain} table of the brand's database. [31m(Greg Amaroso, 28 hours ago)[m
- diff --git a/drupal/drupal-7.9/sites/all/modules/custom/elc_domain/includes/bootstrap.inc b/drupal/drupal-7.9/sites/all/modules/custom/elc_domain/includes/bootstrap.inc
- index d0a0a15..d4a5d36 100644
- --- a/drupal/drupal-7.9/sites/all/modules/custom/elc_domain/includes/bootstrap.inc
- +++ b/drupal/drupal-7.9/sites/all/modules/custom/elc_domain/includes/bootstrap.inc
- @@ -29,6 +29,7 @@ function _elc_domain_directory_aliases(&$sites = NULL) {
- * Add personal site directory aliases to an existing $sites array
- */
- function _elc_domain_personal_site_directory_aliases(&$sites = NULL, $username) {
- + $username = &drupal_static(__FUNCTION__, $username);
- if (empty($username)) {
- return;
- }
- @@ -42,14 +43,52 @@ function _elc_domain_personal_site_directory_aliases(&$sites = NULL, $username)
- if ($environment != 'eng') {
- continue;
- }
- - foreach ($locale as $domains) {
- - array_walk($domains, create_function('&$v, $k', '$v = preg_replace(\'/\.eng\./\', \'.' . $username . '.eng.\', $v);'));
- - foreach ($domains as $domain) {
- - $sites[$domain] = $brand;
- + foreach ($locale as $urls) {
- + _elc_domain_substitute_user_domain_alias($urls, $username);
- + foreach ($urls as $url) {
- + $sites[$url] = $brand;
- + }
- + }
- + }
- + }
- +}
- +
- +/**
- + * Retrieve domain aliases for each brand
- + */
- +function _elc_domain_get_domain_aliases($key) {
- + $domains = _elc_domain_retrieve_master_domain_file();
- + foreach ($domains as $brand => $environments) {
- + foreach ($environments as $environment => $locale) {
- + foreach ($locale as $initial => $urls) {
- + // Create a variable to test against the desired key
- + $key_test = implode('_', array($brand, $environment, $initial));
- +
- + if ($key == $key_test) {
- + // If a sites.local.php files exists, then the directory alias function should be called, and thus we have a static $username variable available
- + $username = &drupal_static('_elc_domain_personal_site_directory_aliases');
- +
- + // If a username does exist, then include the tokenized URLs into the list of domains
- + if (!empty($username)) {
- + $tmp = $urls;
- + _elc_domain_substitute_user_domain_alias($urls, $username, $environment);
- + $urls = array_merge($urls, $tmp);
- + }
- +
- + return array_unique($urls);
- }
- }
- }
- }
- +
- + return array();
- +}
- +
- +/**
- + * This is a function to perform URL pattern substitution - mainly used for personal server setup
- + */
- +function _elc_domain_substitute_user_domain_alias(&$urls, $alias, $env = 'eng') {
- + return array_walk($urls, create_function('&$v, $k', '$v = preg_replace(\'/\.eng\./\', \'.' . $alias . '.' . $env . '.\', $v);'));
- }
- /**
Add Comment
Please, Sign In to add comment