You are here

public function ContentTypeILT::getContent in Opigno Instructor-led Trainings 3.x

Same name and namespace in other branches
  1. 8 src/Plugin/OpignoGroupManagerContentType/ContentTypeILT.php \Drupal\opigno_ilt\Plugin\OpignoGroupManagerContentType\ContentTypeILT::getContent()

Parameters

int|\Drupal\opigno_ilt\ILTInterface $entity: The entity ID or entity instance.

Overrides ContentTypeInterface::getContent

2 calls to ContentTypeILT::getContent()
ContentTypeILT::getAllContents in src/Plugin/OpignoGroupManagerContentType/ContentTypeILT.php
Get all the entities in an array of LearningPathContent.
ContentTypeILT::getContentFromRequest in src/Plugin/OpignoGroupManagerContentType/ContentTypeILT.php
Try to get the content from a Request object.

File

src/Plugin/OpignoGroupManagerContentType/ContentTypeILT.php, line 82

Class

ContentTypeILT
Class ContentTypeILT.

Namespace

Drupal\opigno_ilt\Plugin\OpignoGroupManagerContentType

Code

public function getContent($entity) {

  // If the value is the ILT ID, load the ILT.
  if (is_numeric($entity) || is_string($entity)) {

    /** @var \Drupal\opigno_ilt\ILTInterface $entity */
    $entity = ILT::load($entity);
  }
  if ($entity === NULL || $entity === FALSE) {
    return FALSE;
  }
  return new OpignoGroupContent($this
    ->getPluginId(), $this
    ->getEntityType(), $entity
    ->id(), $entity
    ->label(), $this
    ->getDefaultModuleImageUrl(), t('Default image'));
}