You are here

public function Drupal8::setEntityProperty in Realistic Dummy Content 3.x

Same name and namespace in other branches
  1. 8.2 api/src/Framework/Drupal8.php \Drupal\realistic_dummy_content_api\Framework\Drupal8::setEntityProperty()
  2. 7.2 api/src/Framework/Drupal8.php \Drupal\realistic_dummy_content_api\Framework\Drupal8::setEntityProperty()

Sets the property of an entity.

Overrides Framework::setEntityProperty

File

api/src/Framework/Drupal8.php, line 241

Class

Drupal8
Drupal 8-specific code.

Namespace

Drupal\realistic_dummy_content_api\Framework

Code

public function setEntityProperty(&$entity, $property, $value) {
  if (!isset($value['set'])) {
    $value = (array) $value;
    $value['set'] = $value;
  }
  $entity
    ->set($property, $value['set']);
  if (isset($value['options']['format'])) {
    $entity->{$property}->format = $value['options']['format'];
  }
  unset($entity->{$property}->height);
  unset($entity->{$property}->width);
}