You are here

public function EntityHelper::__construct in Feeds Paragraphs 8

File

tests/src/Unit/Helpers/EntityHelper.php, line 50

Class

EntityHelper

Namespace

Drupal\Tests\feeds_para_mapper\Unit\Helpers

Code

public function __construct(FieldHelper $fieldHelper) {
  $this->prophet = new Prophet();
  $this->node = $this
    ->getEntity('node', $fieldHelper->node_bundle, 100);
  $this->paragraphs = array();
  $this->host_fields_values = array();
  $last = $this->node;
  foreach ($fieldHelper->fieldsConfig as $config) {
    $st = $config->settings['handler_settings'];
    if (isset($st['target_bundles'])) {
      $this->values[$config->name] = array();
      foreach ($st['target_bundles'] as $target_bundle) {
        foreach ($config->paragraph_ids as $paragraph_id) {
          if (isset($config->host_field)) {
            $this->host_fields_values[$config->name] = array(
              array(
                'value' => $config->host_field,
              ),
            );
          }
          $this->paragraphs[$paragraph_id] = $this
            ->getEntity('paragraph', $target_bundle, $paragraph_id, $config->host_field, $last
            ->reveal());
          $this->values[$config->name][] = array(
            'target_id' => $paragraph_id,
          );
          $last = $this->paragraphs[$paragraph_id];
        }
      }
    }
  }
  $this->fieldHelper = $fieldHelper;
}