You are here

function course_get_attached in Course 8.2

Same name and namespace in other branches
  1. 8.3 course.module \course_get_attached()
  2. 3.x course.module \course_get_attached()

Find the Entity that a Course is attached to.

Parameters

Course $course:

string $entity_type:

Return value

Node

File

./course.module, line 482
course.module Core functionality for Courses.

Code

function course_get_attached(Course $course, $entity_type = 'node') {
  $nids = Drupal::entityQuery($entity_type)
    ->condition('field_course', $course
    ->id())
    ->execute();
  if ($nids) {
    return Node::load(reset($nids));
  }
}