Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Added null check. #143

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Commands/TideSiteCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ public function siteEnvDomainUpdate() {
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();
// Check if the term exists before trying to manipulate it.
if ($term) {
$term->set('field_site_domains', str_replace('<br/>', "\r\n", $domain[1]));
$term->save();
}
else {
$this->output()->writeln($this->t('Term with ID @term_id not found.', ['@term_id' => $domain[0]]));
}
}
$this->output()->writeln($this->t('Domains Updated.'));
}
Expand Down