You are here

public function OpignoUserSelectionController::getGroupImage in Opigno Learning path 3.x

@opigno_deprecated

2 calls to OpignoUserSelectionController::getGroupImage()
OpignoUserSelectionController::post in modules/opigno_user_selection/src/Controller/OpignoUserSelectionController.php
OpignoUserSelectionController::training in modules/opigno_user_selection/src/Controller/OpignoUserSelectionController.php

File

modules/opigno_user_selection/src/Controller/OpignoUserSelectionController.php, line 101

Class

OpignoUserSelectionController
Returns responses for Opigno User Selection routes.

Namespace

Drupal\opigno_user_selection\Controller

Code

public function getGroupImage($type, $group) {
  $default_image = file_create_url(drupal_get_path('module', 'opigno_user_selection') . '/assets/' . $type . '.svg');
  $image_style = ImageStyle::load('thumbnail');
  if (!$image_style instanceof ImageStyle) {
    return $default_image;
  }
  $media = $this
    ->getEntityField($group, 'field_learning_path_media_image');
  if (!$media instanceof Media) {
    return $default_image;
  }
  $file = $this
    ->getEntityField($media, 'field_media_image');
  if (!$file instanceof File) {
    return $default_image;
  }
  return $image_style
    ->buildUrl($file
    ->getFileUri());
}