You are here

protected function EntityConfigBase::updateEntityProperty in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php \Drupal\migrate\Plugin\migrate\destination\EntityConfigBase::updateEntityProperty()
  2. 10 core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php \Drupal\migrate\Plugin\migrate\destination\EntityConfigBase::updateEntityProperty()

Updates a (possible nested) entity property with a value.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The config entity.

array $parents: The array of parents.

string|object $value: The value to update to.

2 calls to EntityConfigBase::updateEntityProperty()
EntityConfigBase::updateEntity in core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
Updates an entity with the contents of a row.
EntityDateFormat::updateEntityProperty in core/modules/system/src/Plugin/migrate/destination/EntityDateFormat.php
1 method overrides EntityConfigBase::updateEntityProperty()
EntityDateFormat::updateEntityProperty in core/modules/system/src/Plugin/migrate/destination/EntityDateFormat.php

File

core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php, line 229

Class

EntityConfigBase
Base destination class for importing configuration entities.

Namespace

Drupal\migrate\Plugin\migrate\destination

Code

protected function updateEntityProperty(EntityInterface $entity, array $parents, $value) {
  $top_key = array_shift($parents);
  $entity_value = $entity
    ->get($top_key);
  if (is_array($entity_value)) {
    NestedArray::setValue($entity_value, $parents, $value);
  }
  else {
    $entity_value = $value;
  }
  $entity
    ->set($top_key, $entity_value);
}