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

Commit

Permalink
Added null check. (#143)
Browse files Browse the repository at this point in the history
* Added null check.
  • Loading branch information
MdNadimHossain authored Nov 22, 2023
1 parent 23c1939 commit fb2e6c8
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit fb2e6c8

Please sign in to comment.