You are here

public function ForumTopicHandler::getForumTopicGroupId in Opigno forum 8

Same name and namespace in other branches
  1. 3.x src/ForumTopicHandler.php \Drupal\opigno_forum\ForumTopicHandler::getForumTopicGroupId()

Returns the group associated with the specified topic.

Parameters

\Drupal\node\NodeInterface $topic: A forum topic node object.

Return value

string|null A group ID.

1 call to ForumTopicHandler::getForumTopicGroupId()
ForumTopicHandler::onNodeInsert in src/ForumTopicHandler.php
Performs node creation tasks.

File

src/ForumTopicHandler.php, line 133

Class

ForumTopicHandler
Handles the relationship between forum topics and groups.

Namespace

Drupal\opigno_forum

Code

public function getForumTopicGroupId(NodeInterface $topic) {
  $tid = $topic
    ->get('taxonomy_forums')->target_id;
  $ids = $this->entityTypeManager
    ->getStorage('group')
    ->getQuery()
    ->condition('field_learning_path_enable_forum', 1)
    ->condition('field_learning_path_forum', $tid)
    ->accessCheck(FALSE)
    ->execute();
  return $ids ? reset($ids) : NULL;
}