Skip to content

Commit

Permalink
Merge pull request #15 from essexcountycouncil/fix/LP-90-field
Browse files Browse the repository at this point in the history
fix(LP-90): Check fields exist
  • Loading branch information
Polynya committed Sep 25, 2024
2 parents b645c63 + b4e8c8d commit fac423f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Commands/ContentOwnership.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,17 @@ public function addServiceContactsToNodes() {
foreach ($node_storage->loadMultiple($ids) as $node) {
$content_owners = [];
// Combine content owners of both types without duplication.
foreach ($node->get('field_content_owner')->referencedEntities() as $entity) {
$content_owners[$entity->id()] = $entity;
if ($node->hasField('field_content_owner')) {
foreach ($node->get('field_content_owner')
->referencedEntities() as $entity) {
$content_owners[$entity->id()] = $entity;
}
}
foreach ($node->get('field_content_sme')->referencedEntities() as $entity) {
$content_owners[$entity->id()] = $entity;
if ($node->hasField('field_content_sme')) {
foreach ($node->get('field_content_sme')
->referencedEntities() as $entity) {
$content_owners[$entity->id()] = $entity;
}
}

$count = 0;
Expand Down

0 comments on commit fac423f

Please sign in to comment.