diff --git a/domain_group.module b/domain_group.module index b7e1ce6..3b45a66 100644 --- a/domain_group.module +++ b/domain_group.module @@ -11,6 +11,7 @@ use Drupal\node\NodeInterface; use Drupal\Core\Session\AccountInterface; use Drupal\group\Entity\GroupContentType; use Drupal\Core\Access\AccessResult; +use Drupal\domain\Entity\Domain; /** * Implements hook_help(). @@ -205,9 +206,12 @@ function domain_group_node_get_domains(NodeInterface $node) { $group_content = GroupContent::loadByEntity($node); if (!empty($group_content)) { foreach ($group_content as $gc_node) { - $domain = \Drupal::entityTypeManager()->getStorage('domain')->load('group_' . $gc_node->getGroup()->id()); - if ($domain) { - $domains[$domain->id()] = $domain->getDomainId(); + $group = $gc_node->getGroup(); + if ($group) { + $domain = \Drupal::entityTypeManager()->getStorage('domain')->load('group_' . $group->id()); + if ($domain) { + $domains[$domain->id()] = $domain->getDomainId(); + } } } }