You are here

public function ContentTypeModule::getContent in Opigno module 8

Same name and namespace in other branches
  1. 3.x src/Plugin/OpignoGroupManagerContentType/ContentTypeModule.php \Drupal\opigno_module\Plugin\OpignoGroupManagerContentType\ContentTypeModule::getContent()

Get the entity as a LearningPathContent.

Parameters

int $entity_id: The entity ID.

Return value

\Drupal\opigno_group_manager\OpignoGroupContent|false The content loaded in a LearningPathContent. FALSE if not possible to load.

Overrides ContentTypeInterface::getContent

File

src/Plugin/OpignoGroupManagerContentType/ContentTypeModule.php, line 106

Class

ContentTypeModule
Class ContentTypeModule.

Namespace

Drupal\opigno_module\Plugin\OpignoGroupManagerContentType

Code

public function getContent($entity_id) {
  $module = OpignoModule::load($entity_id);
  $request = \Drupal::request();
  return new OpignoGroupContent($this
    ->getPluginId(), $this
    ->getEntityType(), $entity_id, $module
    ->label(), ($image_url = $this
    ->getModuleImageUrl($module)) ? $image_url : $this
    ->getDefaultModuleImageUrl(), $image_url ? $this
    ->getModuleImageAlt($module) : t('Default image'));
}