You are here

protected function ImportTrainingForm::buildEntityOptions in Opigno module 8

Same name and namespace in other branches
  1. 3.x src/Form/ImportTrainingForm.php \Drupal\opigno_module\Form\ImportTrainingForm::buildEntityOptions()

Build Array of settings to create entity.

Parameters

array $source: List of values from imported file.

string $type: Type of entity.

Return value

array

3 calls to ImportTrainingForm::buildEntityOptions()
ImportTrainingForm::importCourse in src/Form/ImportTrainingForm.php
Create Course entity.
ImportTrainingForm::importModule in src/Form/ImportTrainingForm.php
Create Opigno Module entity.
ImportTrainingForm::importTraining in src/Form/ImportTrainingForm.php
Create training entity.

File

src/Form/ImportTrainingForm.php, line 564

Class

ImportTrainingForm
Import Course form.

Namespace

Drupal\opigno_module\Form

Code

protected function buildEntityOptions($source, $type) {
  $build = [
    'type' => $type,
  ];
  $fields = $this
    ->fieldColections($type);
  foreach ($fields as $field) {
    if (!empty($source[$field][0]['value'])) {
      $build[$field] = $source[$field][0]['value'];
    }
  }
  return $build;
}