You are here

public static function LPManagedContent::getFirstStep in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/Entity/LPManagedContent.php \Drupal\opigno_learning_path\Entity\LPManagedContent::getFirstStep()

Returns first step.

File

src/Entity/LPManagedContent.php, line 348

Class

LPManagedContent
Defines the Learning Path Content entity.

Namespace

Drupal\opigno_learning_path\Entity

Code

public static function getFirstStep($learning_path_id) {

  // The first step is the content who has no parents.
  // First, get all the contents.
  $contents = self::loadByLearningPathId($learning_path_id);

  // Then, check which content has no parent link.
  foreach ($contents as $content) {
    $parents = $content
      ->getParentsLinks();
    if (empty($parents)) {
      return $content;
    }
  }
  return FALSE;
}