You are here

public static function OpignoGroupManagedContent::getFirstStep in Opigno group manager 3.x

Same name and namespace in other branches
  1. 8 src/Entity/OpignoGroupManagedContent.php \Drupal\opigno_group_manager\Entity\OpignoGroupManagedContent::getFirstStep()

Returns first step.

File

src/Entity/OpignoGroupManagedContent.php, line 465

Class

OpignoGroupManagedContent
Defines the Opigno Group Content entity.

Namespace

Drupal\opigno_group_manager\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::loadByGroupId($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;
}