This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release/2.0.4
- Loading branch information
Showing
6 changed files
with
102 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
services: | ||
tide_site.commands: | ||
class: \Drupal\tide_site\Commands\TideSiteCommands | ||
tags: | ||
- { name: drush.command } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Drupal\tide_site\Commands; | ||
|
||
use Drush\Commands\DrushCommands; | ||
|
||
/** | ||
* A Drush commandfile. | ||
* | ||
* In addition to this file, you need a drush.services.yml | ||
* in root of your module, and a composer.json file that provides the name | ||
* of the services file to use. | ||
* | ||
* See these files for an example of injecting Drupal services: | ||
* - http://cgit.drupalcode.org/devel/tree/src/Commands/DevelCommands.php | ||
* - http://cgit.drupalcode.org/devel/tree/drush.services.yml | ||
*/ | ||
class TideSiteCommands extends DrushCommands { | ||
|
||
/** | ||
* Update the domains on the site taxonomy based on an environment variable. | ||
* | ||
* @usage drush tide-site-env-domain-update | ||
* Update the domains on the site taxonomy based on an environment variable. | ||
* | ||
* @command tide:site-env-domain-update | ||
* @aliases tide-si-domup,tide-site-env-domain-update | ||
* @throws \Exception | ||
*/ | ||
public function siteEnvDomainUpdate() { | ||
try { | ||
$environment = getenv('LAGOON_GIT_BRANCH'); | ||
if ($environment == 'production') { | ||
$this->output()->writeln(t('This command cannot run in Lagoon production environments.')); | ||
} | ||
else { | ||
$fe_domains = getenv('FE_DOMAINS'); | ||
if (!empty($fe_domains)) { | ||
foreach (explode(',', $fe_domains) as $fe_domain) { | ||
$domain = explode('|', $fe_domain); | ||
$term = Term::load($domain[0]); | ||
$term->set('field_site_domains', str_replace('<br/>', "\r\n", $domain[1])); | ||
$term->save(); | ||
} | ||
$this->output()->writeln(t('Domains Updated.')); | ||
} | ||
else { | ||
$this->output()->writeln(t('No site specific domains were found in this environment.')); | ||
} | ||
} | ||
} | ||
catch (ConsoleException $exception) { | ||
throw new \Exception($exception->getMessage()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters