You are here

protected function ContentTypeCourse::getCourseImage in Opigno course 8

Same name and namespace in other branches
  1. 3.x src/Plugin/OpignoGroupManagerContentType/ContentTypeCourse.php \Drupal\opigno_course\Plugin\OpignoGroupManagerContentType\ContentTypeCourse::getCourseImage()

Method for getting image from Course.

4 calls to ContentTypeCourse::getCourseImage()
ContentTypeCourse::getAllContents in src/Plugin/OpignoGroupManagerContentType/ContentTypeCourse.php
Get all the entities in an array of LearningPathContent.
ContentTypeCourse::getAvailableContents in src/Plugin/OpignoGroupManagerContentType/ContentTypeCourse.php
Get all the published entities in an array of LearningPathContent.
ContentTypeCourse::getContent in src/Plugin/OpignoGroupManagerContentType/ContentTypeCourse.php
Get the entity as a LearningPathContent.
ContentTypeCourse::getContentFromRequest in src/Plugin/OpignoGroupManagerContentType/ContentTypeCourse.php
Try to get the content from a Request object.

File

src/Plugin/OpignoGroupManagerContentType/ContentTypeCourse.php, line 350

Class

ContentTypeCourse
Class ContentTypeCourse.

Namespace

Drupal\opigno_course\Plugin\OpignoGroupManagerContentType

Code

protected function getCourseImage($group) {
  if (!$group
    ->hasField('field_course_media_image')) {
    return FALSE;
  }
  $image = FALSE;

  // Get media.
  if ($media = $group
    ->get('field_course_media_image')->entity) {

    // Get image.
    $image = $media
      ->get('field_media_image');
  }
  return $image;
}