protected function StepsBlock::getTrainingAndCourse in Opigno Learning path 3.x
Loading a training/course and module entities by step array.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to StepsBlock::getTrainingAndCourse()
- StepsBlock::processActivityList in src/
Plugin/ Block/ StepsBlock.php - Converts a step array to a renderable array.
File
- src/
Plugin/ Block/ StepsBlock.php, line 288
Class
- StepsBlock
- Provides a 'article' block.
Namespace
Drupal\opigno_learning_path\Plugin\BlockCode
protected function getTrainingAndCourse($step) : array {
$step_training = $this
->getStepTraining($step);
if (!$step_training) {
$step_training = [
'cid' => $step['cid'],
'id' => FALSE,
];
}
/** @var \Drupal\opigno_group_manager\OpignoGroupContent $content */
$content = $this
->entityTypeManager()
->getStorage('opigno_group_content')
->load($step_training["cid"]);
$training = $content instanceof OpignoGroupManagedContent ? $content
->getGroup() : NULL;
$course = $step_training["id"] ? $this
->entityTypeManager()
->getStorage('group')
->load($step_training["id"]) : FALSE ?: NULL;
$module = $this
->entityTypeManager()
->getStorage('opigno_module')
->load($step["id"]) ?: NULL;
return [
$training,
$course,
$module,
];
}