You are here

public static function LPManagedLink::createWithValues in Opigno Learning path 8

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

Helper method to create a new LPManagedLink.

It's not saved on creation. You have to do $obj->save() to save it in DB.

Parameters

int $learning_path_id: The learning path group ID.

int $parent_content_id: The parent content ID.

int $child_content_id: The child content ID.

int $required_score: The required score to go from the parent to the child content.

Return value

\Drupal\Core\Entity\EntityInterface|self LPManagedLink object.

2 calls to LPManagedLink::createWithValues()
LearningPathManagerController::addLink in src/Controller/LearningPathManagerController.php
Add a new link in the Learning Path.
LearningPathManagerController::updateLink in src/Controller/LearningPathManagerController.php
Update a link minimum score to go to next step.

File

src/Entity/LPManagedLink.php, line 47

Class

LPManagedLink
Defines the Learning Path Link entity.

Namespace

Drupal\opigno_learning_path\Entity

Code

public static function createWithValues($learning_path_id, $parent_content_id, $child_content_id, $required_score = 0) {
  $values = [
    'learning_path_id' => $learning_path_id,
    'parent_content_id' => $parent_content_id,
    'child_content_id' => $child_content_id,
    'required_score' => $required_score,
  ];
  return parent::create($values);
}