private function TrainingContentTrait::createContentForTraining in Opigno Learning path 8
Same name and namespace in other branches
- 3.x tests/src/Functional/TrainingContentTrait.php \Drupal\Tests\opigno_learning_path\Functional\TrainingContentTrait::createContentForTraining()
Creates training content.
1 call to TrainingContentTrait::createContentForTraining()
- TrainingContentTrait::addModuleToTraining in tests/
src/ Functional/ TrainingContentTrait.php - Add Module to a Training.
File
- tests/
src/ Functional/ TrainingContentTrait.php, line 100
Class
- TrainingContentTrait
- Trait TrainingContentTrait.
Namespace
Drupal\Tests\opigno_learning_path\FunctionalCode
private function createContentForTraining($content_item, $content_type, $group, $is_mandatory = 1) {
// Create the added item as an group content.
$group_content = OpignoGroupManagedContent::createWithValues($group
->id(), $content_type, $content_item
->id(), 0, $is_mandatory);
$group_content
->save();
$content_types_manager = \Drupal::service('opigno_group_manager.content_types.manager');
$plugin_definition = $content_types_manager
->getDefinition($content_type);
$added_entity = \Drupal::entityTypeManager()
->getStorage($plugin_definition['entity_type'])
->load($content_item
->id());
$group
->addContent($added_entity, $plugin_definition['group_content_plugin_id']);
return $group;
}