You are here

public function EntityStatus::setData in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/Entity/EntityStatus.php \Drupal\cms_content_sync\Entity\EntityStatus::setData()
  2. 2.0.x src/Entity/EntityStatus.php \Drupal\cms_content_sync\Entity\EntityStatus::setData()

Set a key=>value pair.

Parameters

string|string[] $key: The key to set (for hierarchical usage, provide an array of indices

mixed $value: The value to set. Must be a valid value for Drupal's "map" storage (so basic types that can be serialized).

4 calls to EntityStatus::setData()
EntityStatus::didPullFail in src/Entity/EntityStatus.php
Returns the information if the last pull of the entity failed.
EntityStatus::didPushFail in src/Entity/EntityStatus.php
Returns the information if the last push of the entity failed.
EntityStatus::setEntityPushHash in src/Entity/EntityStatus.php
EntityStatus::setParentEntity in src/Entity/EntityStatus.php
If an entity is pushed or pulled embedded into another entity, we store that parent entity here. This is required so that at a later point we can still force pull and force push the embedded entity although it doesn't exist individually. This is…

File

src/Entity/EntityStatus.php, line 1067

Class

EntityStatus
Defines the "Content Sync - Entity Status" entity type.

Namespace

Drupal\cms_content_sync\Entity

Code

public function setData($key, $value) {
  $data = $this
    ->get('data')
    ->getValue();
  if (!empty($data)) {
    $data = $data[0];
  }
  else {
    $data = [];
  }
  $storage =& $data;
  if (is_string($key) && null === $value) {
    if (isset($data[$key])) {
      unset($data[$key]);
    }
  }
  else {
    if (!is_array($key)) {
      $key = [
        $key,
      ];
    }
    foreach ($key as $index) {
      if (!isset($storage[$index])) {
        $storage[$index] = [];
      }
      $storage =& $storage[$index];
    }
    $storage = $value;
  }
  $this
    ->set('data', $data);
}