You are here

class EntityStatus 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
  2. 2.0.x src/Entity/EntityStatus.php \Drupal\cms_content_sync\Entity\EntityStatus

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

Plugin annotation


@ContentEntityType(
  id = "cms_content_sync_entity_status",
  label = @Translation("Content Sync - Entity Status"),
  base_table = "cms_content_sync_entity_status",
  entity_keys = {
    "id" = "id",
    "flow" = "flow",
    "pool" = "pool",
    "entity_uuid" = "entity_uuid",
    "entity_type" = "entity_type",
    "entity_type_version" = "entity_type_version",
    "flags" = "flags",
  },
  handlers = {
    "views_data" = "Drupal\views\EntityViewsData",
    "storage_schema" = "Drupal\cms_content_sync\EntityStatusStorageSchema",
  },
)

Hierarchy

Expanded class hierarchy of EntityStatus

25 files declare their use of EntityStatus
CliService.php in src/Cli/CliService.php
cms_content_sync.module in ./cms_content_sync.module
Module file for cms_content_sync.
cms_content_sync_views.module in modules/cms_content_sync_views/cms_content_sync_views.module
Module file for cms_content_sync_views.
CreateStatusEntities.php in modules/cms_content_sync_migrate_acquia_content_hub/src/CreateStatusEntities.php
DebugForm.php in src/Form/DebugForm.php

... See full list

File

src/Entity/EntityStatus.php, line 38

Namespace

Drupal\cms_content_sync\Entity
View source
class EntityStatus extends ContentEntityBase implements EntityStatusInterface {
  use EntityChangedTrait;
  public const FLAG_UNUSED_CLONED = 0x1;
  public const FLAG_DELETED = 0x2;
  public const FLAG_USER_ENABLED_PUSH = 0x4;
  public const FLAG_EDIT_OVERRIDE = 0x8;
  public const FLAG_IS_SOURCE_ENTITY = 0x10;
  public const FLAG_PUSH_ENABLED = 0x20;
  public const FLAG_DEPENDENCY_PUSH_ENABLED = 0x40;
  public const FLAG_LAST_PUSH_RESET = 0x80;
  public const FLAG_LAST_PULL_RESET = 0x100;
  public const FLAG_PUSH_FAILED = 0x200;
  public const FLAG_PULL_FAILED = 0x400;
  public const FLAG_PUSH_FAILED_SOFT = 0x800;
  public const FLAG_PULL_FAILED_SOFT = 0x1000;
  public const FLAG_PUSHED_EMBEDDED = 0x2000;
  public const FLAG_PULLED_EMBEDDED = 0x4000;
  public const DATA_PULL_FAILURE = 'import_failure';
  public const DATA_PUSH_FAILURE = 'export_failure';
  public const DATA_ENTITY_PUSH_HASH = 'entity_push_hash';
  public const DATA_PARENT_ENTITY = 'parent_entity';
  public const FLOW_NO_FLOW = 'ERROR_STATUS_ENTITY_FLOW';

  /**
   * {@inheritdoc}
   */
  public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {

    // Set Entity ID or UUID by default one or the other is not set.
    if (!isset($values['entity_type'])) {
      throw new \Exception(t('The type of the entity is required.'));
    }
    if (!isset($values['flow'])) {
      throw new \Exception(t('The flow is required.'));
    }
    if (!isset($values['pool'])) {
      throw new \Exception(t('The pool is required.'));
    }

    /**
     * @var \Drupal\Core\Entity\EntityInterface $entity
     */
    $entity = \Drupal::service('entity.repository')
      ->loadEntityByUuid($values['entity_type'], $values['entity_uuid']);
    if (!isset($values['entity_type_version'])) {
      $values['entity_type_version'] = Flow::getEntityTypeVersion($entity
        ->getEntityType()
        ->id(), $entity
        ->bundle());
      return;
    }
  }

  /**
   * @param string $entity_type
   * @param string $entity_uuid
   *
   * @throws \Exception
   *
   * @return EntityStatus[]
   */
  public static function getInfoForPool($entity_type, $entity_uuid, Pool $pool) {
    if (!$entity_type) {
      throw new \Exception('$entity_type is required.');
    }
    if (!$entity_uuid) {
      throw new \Exception('$entity_uuid is required.');
    }

    /**
     * @var EntityStatus[] $entities
     */
    return \Drupal::entityTypeManager()
      ->getStorage('cms_content_sync_entity_status')
      ->loadByProperties([
      'entity_type' => $entity_type,
      'entity_uuid' => $entity_uuid,
      'pool' => $pool->id,
    ]);
  }

  /**
   * Get a list of all entity status entities for the given entity.
   *
   * @param string $entity_type
   *                            The entity type ID
   * @param string $entity_uuid
   *                            The entity UUID
   * @param array  $filter
   *                            Additional filters. Usually "flow"=>... or "pool"=>...
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   *
   * @return EntityStatus[]
   */
  public static function getInfosForEntity($entity_type, $entity_uuid, $filter = null) {
    if (!$entity_type) {
      throw new \Exception('$entity_type is required.');
    }
    if (!$entity_uuid) {
      throw new \Exception('$entity_uuid is required.');
    }
    $base_filter = [
      'entity_type' => $entity_type,
      'entity_uuid' => $entity_uuid,
    ];
    $filters_combined = $base_filter;
    $filter_without_flow = isset($filter['flow']) && (empty($filter['flow']) || self::FLOW_NO_FLOW == $filter['flow']);
    if ($filter_without_flow) {
      $filters_combined = array_merge($filters_combined, [
        'flow' => self::FLOW_NO_FLOW,
      ]);
    }
    elseif ($filter) {
      $filters_combined = array_merge($filters_combined, $filter);
    }

    /**
     * @var EntityStatus[] $entities
     */
    $entities = \Drupal::entityTypeManager()
      ->getStorage('cms_content_sync_entity_status')
      ->loadByProperties($filters_combined);
    $result = [];

    // If a pull fails, we may create a status entity without a flow assigned.
    // We ignore them for normal functionality, so they're filtered out.
    if ($filter_without_flow) {
      foreach ($entities as $i => $entity) {
        if (!$entity
          ->getFlow()) {
          $result[] = $entity;
        }
      }
    }
    else {
      foreach ($entities as $i => $entity) {
        if ($entity
          ->getFlow()) {
          $result[] = $entity;
        }
      }
    }
    return $result;
  }

  /**
   * @param string      $entity_type
   * @param string      $entity_uuid
   * @param Flow|string $flow
   * @param Pool|string $pool
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   * @throws \Exception
   *
   * @return EntityStatus|mixed
   */
  public static function getInfoForEntity($entity_type, $entity_uuid, $flow, $pool) {
    if (!$entity_type) {
      throw new \Exception('$entity_type is required.');
    }
    if (!$entity_uuid) {
      throw new \Exception('$entity_uuid is required.');
    }
    $filter = [
      'entity_type' => $entity_type,
      'entity_uuid' => $entity_uuid,
      'pool' => is_string($pool) ? $pool : $pool->id,
    ];
    if ($flow) {
      $filter['flow'] = is_string($flow) ? $flow : $flow->id;
    }
    else {
      $filter['flow'] = self::FLOW_NO_FLOW;
    }

    /**
     * @var EntityStatus[] $entities
     */
    $entities = \Drupal::entityTypeManager()
      ->getStorage('cms_content_sync_entity_status')
      ->loadByProperties($filter);
    if (!$flow) {
      foreach ($entities as $entity) {
        if (!$entity
          ->getFlow()) {
          return $entity;
        }
      }
      return null;
    }
    return reset($entities);
  }

  /**
   * @param $entity
   */
  public function resetStatus() {
    $this
      ->setLastPush(null);
    $this
      ->setLastPull(null);
    $this
      ->save();

    // Above cache clearing doesn't work reliably. So we reset the whole entity cache.
    \Drupal::service('cache.entity')
      ->deleteAll();
  }

  /**
   * @throws \Exception
   *
   * @return null|int
   */
  public static function getLastPushForEntity(EntityInterface $entity) {
    $entity_status = EntityStatus::getInfosForEntity($entity
      ->getEntityTypeId(), $entity
      ->uuid());
    $latest = null;
    foreach ($entity_status as $info) {
      if ($info
        ->getLastPush() && (!$latest || $info
        ->getLastPush() > $latest)) {
        $latest = $info
          ->getLastPush();
      }
    }
    return $latest;
  }

  /**
   * @throws \Exception
   *
   * @return null|int
   */
  public static function getLastPullForEntity(EntityInterface $entity) {
    $entity_status = EntityStatus::getInfosForEntity($entity
      ->getEntityTypeId(), $entity
      ->uuid());
    $latest = null;
    foreach ($entity_status as $info) {
      if ($info
        ->getLastPull() && (!$latest || $info
        ->getLastPull() > $latest)) {
        $latest = $info
          ->getLastPull();
      }
    }
    return $latest;
  }

  /**
   * @param mixed      $entity_type
   * @param mixed      $uuid
   * @param mixed      $field_name
   * @param mixed      $delta
   * @param mixed      $tree_position
   * @param null|mixed $set_flow_id
   * @param null|mixed $set_pool_ids
   * @param null|mixed $set_uuid
   */
  public static function accessTemporaryPushToPoolInfoForField($entity_type, $uuid, $field_name, $delta, $tree_position = [], $set_flow_id = null, $set_pool_ids = null, $set_uuid = null) {
    static $field_storage = [];
    if ($set_flow_id && $set_pool_ids) {
      $data = [
        'flow_id' => $set_flow_id,
        'pool_ids' => $set_pool_ids,
        'uuid' => $set_uuid,
      ];
      if (!isset($field_storage[$entity_type][$uuid])) {
        $field_storage[$entity_type][$uuid] = [];
      }
      $setter =& $field_storage[$entity_type][$uuid];
      foreach ($tree_position as $name) {
        if (!isset($setter[$name])) {
          $setter[$name] = [];
        }
        $setter =& $setter[$name];
      }
      if (!isset($setter[$field_name][$delta])) {
        $setter[$field_name][$delta] = [];
      }
      $setter =& $setter[$field_name][$delta];
      $setter = $data;
    }
    else {
      if (!empty($field_storage[$entity_type][$uuid])) {
        $value = $field_storage[$entity_type][$uuid];
        foreach ($tree_position as $name) {
          if (!isset($value[$name])) {
            return null;
          }
          $value = $value[$name];
        }
        return isset($value[$field_name][$delta]) ? $value[$field_name][$delta] : null;
      }
    }
    return null;
  }

  /**
   * @param \Drupal\Core\Entity\EntityInterface $parent_entity
   * @param string                              $parent_field_name
   * @param int                                 $parent_field_delta
   * @param \Drupal\Core\Entity\EntityInterface $reference
   * @param array                               $tree_position
   */
  public static function saveSelectedPushToPoolForField($parent_entity, $parent_field_name, $parent_field_delta, $reference, $tree_position = []) {
    $data = EntityStatus::accessTemporaryPushToPoolInfoForField($parent_entity
      ->getEntityTypeId(), $parent_entity
      ->uuid(), $parent_field_name, $parent_field_delta, $tree_position);

    // On sites that don't push, this will be NULL.
    if (empty($data['flow_id'])) {
      return;
    }
    $values = $data['pool_ids'];
    $processed = [];
    if (is_array($values)) {
      foreach ($values as $id => $selected) {
        if ($selected && 'ignore' !== $id) {
          $processed[] = $id;
        }
      }
    }
    else {
      if ('ignore' !== $values) {
        $processed[] = $values;
      }
    }
    EntityStatus::saveSelectedPoolsToPushTo($reference, $data['flow_id'], $processed, $parent_entity, $parent_field_name);
  }

  /**
   * @param \Drupal\Core\Entity\EntityInterface $reference
   * @param string                              $flow_id
   * @param string[]                            $pool_ids
   * @param null|EntityInterface                $parent_entity
   * @param null|string                         $parent_field_name
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   * @throws \Drupal\Core\Entity\EntityStorageException
   */
  public static function saveSelectedPoolsToPushTo($reference, $flow_id, $pool_ids, $parent_entity = null, $parent_field_name = null) {
    $entity_type = $reference
      ->getEntityTypeId();
    $bundle = $reference
      ->bundle();
    $uuid = $reference
      ->uuid();
    $flow = Flow::getAll()[$flow_id];
    $pools = Pool::getAll();
    $entity_type_pools = Pool::getSelectablePools($entity_type, $bundle, $parent_entity, $parent_field_name)[$flow_id]['pools'];
    foreach ($entity_type_pools as $entity_type_pool_id => $config) {
      $pool = $pools[$entity_type_pool_id];
      $entity_status = EntityStatus::getInfoForEntity($entity_type, $uuid, $flow, $pool);
      if (in_array($entity_type_pool_id, $pool_ids)) {
        if (!$entity_status) {
          $entity_status = EntityStatus::create([
            'flow' => $flow->id,
            'pool' => $pool->id,
            'entity_type' => $entity_type,
            'entity_uuid' => $uuid,
            'entity_type_version' => Flow::getEntityTypeVersion($entity_type, $bundle),
            'flags' => 0,
            'source_url' => null,
          ]);
        }
        $entity_status
          ->isPushEnabled(true);
        $entity_status
          ->save();
        continue;
      }
      if ($entity_status) {
        $entity_status
          ->isPushEnabled(false);
        $entity_status
          ->save();
      }
    }

    // Also check if the entity is going to be force pushed into another pool.
    $force_push_pools = $flow
      ->getPoolsToPushTo($reference, PushIntent::PUSH_FORCED, SyncIntent::ACTION_CREATE);
    if (count($entity_type_pools) && !count($pool_ids) && !count($force_push_pools)) {
      \Drupal::messenger()
        ->addWarning(\Drupal::translation()
        ->translate("You didn't assign a pool to @entity_type %entity_label so it won't be pushed along with the content.", [
        '@entity_type' => $entity_type,
        '%entity_label' => $reference
          ->label(),
      ]));
    }
    elseif (count($entity_type_pools) && !count($pool_ids) && count($force_push_pools)) {
      $pools = '';
      $numItems = count($force_push_pools);
      $i = 0;
      if (count($force_push_pools) > 1) {
        foreach ($force_push_pools as $force_push_pool) {
          if (++$i === $numItems) {
            $pools .= $force_push_pool
              ->label();
          }
          else {
            $pools .= $force_push_pool
              ->label() . ', ';
          }
        }
      }
      else {
        foreach ($force_push_pools as $force_push_pool) {
          $pools = $force_push_pool
            ->label();
        }
      }
      \Drupal::messenger()
        ->addWarning(\Drupal::translation()
        ->translate("You didn't assign a pool to @entity_type %entity_label, but it is going to be force pushed to the following pools based on the content sync configuration: %pools.", [
        '%pools' => $pools,
        '@entity_type' => $entity_type,
        '%entity_label' => $reference
          ->label(),
      ]));
    }
  }

  /**
   * Get the entity this entity status belongs to.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   */
  public function getEntity() {
    return \Drupal::service('entity.repository')
      ->loadEntityByUuid($this
      ->getEntityTypeName(), $this
      ->getUuid());
  }

  /**
   * Returns the information if the entity has been pushed before but the last push date was reset.
   *
   * @param bool $set
   *                  Optional parameter to set the value for LastPushReset
   *
   * @return bool
   */
  public function wasLastPushReset($set = null) {
    if (true === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value | self::FLAG_LAST_PUSH_RESET);
    }
    elseif (false === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value & ~self::FLAG_LAST_PUSH_RESET);
    }
    return (bool) ($this
      ->get('flags')->value & self::FLAG_LAST_PUSH_RESET);
  }

  /**
   * Returns the information if the entity has been pulled before but the last import date was reset.
   *
   * @param bool $set
   *                  Optional parameter to set the value for LastPullReset
   *
   * @return bool
   */
  public function wasLastPullReset($set = null) {
    if (true === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value | self::FLAG_LAST_PULL_RESET);
    }
    elseif (false === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value & ~self::FLAG_LAST_PULL_RESET);
    }
    return (bool) ($this
      ->get('flags')->value & self::FLAG_LAST_PULL_RESET);
  }

  /**
   * Returns the information if the last push of the entity failed.
   *
   * @param bool       $set
   *                            Optional parameter to set the value for PushFailed
   * @param bool       $soft
   *                            A soft fail- this was intended according to configuration. But the user might want to know why to debug different
   *                            expectations.
   * @param null|array $details
   *                            If $set is TRUE, you can provide additional details on why the push failed. Can be gotten via
   *                            ->whyDidPushFail()
   *
   * @return bool
   */
  public function didPushFail($set = null, $soft = false, $details = null) {
    $flag = $soft ? self::FLAG_PUSH_FAILED_SOFT : self::FLAG_PUSH_FAILED;
    if (true === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value | $flag);
      if (!empty($details)) {
        $this
          ->setData(self::DATA_PUSH_FAILURE, $details);
      }
    }
    elseif (false === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value & ~$flag);
      $this
        ->setData(self::DATA_PUSH_FAILURE, null);
    }
    return (bool) ($this
      ->get('flags')->value & $flag);
  }

  /**
   * Get the details provided to ->didPushFail( TRUE, ... ) before.
   *
   * @return null|array
   */
  public function whyDidPushingFail() {
    return $this
      ->getData(self::DATA_PUSH_FAILURE);
  }

  /**
   * Returns the information if the last pull of the entity failed.
   *
   * @param bool       $set
   *                            Optional parameter to set the value for PullFailed
   * @param bool       $soft
   *                            A soft fail- this was intended according to configuration. But the user might want to know why to debug different
   *                            expectations.
   * @param null|array $details
   *                            If $set is TRUE, you can provide additional details on why the pull failed. Can be gotten via
   *                            ->whyDidPullFail()
   *
   * @return bool
   */
  public function didPullFail($set = null, $soft = false, $details = null) {
    $flag = $soft ? self::FLAG_PULL_FAILED_SOFT : self::FLAG_PULL_FAILED;
    if (true === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value | $flag);
      if (!empty($details)) {
        $this
          ->setData(self::DATA_PULL_FAILURE, $details);
      }
    }
    elseif (false === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value & ~$flag);
      $this
        ->setData(self::DATA_PULL_FAILURE, null);
    }
    return (bool) ($this
      ->get('flags')->value & $flag);
  }

  /**
   * Get the details provided to ->didPullFail( TRUE, ... ) before.
   *
   * @return null|array
   */
  public function whyDidPullingFail() {
    return $this
      ->getData(self::DATA_PULL_FAILURE);
  }

  /**
   * Returns the information if the entity has been chosen by the user to
   * be pushed with this flow and pool.
   *
   * @param bool $set
   *                            Optional parameter to set the value for PushEnabled
   * @param bool $setDependency
   *                            Optional parameter to set the value for DependencyPushEnabled
   *
   * @return bool
   */
  public function isPushEnabled($set = null, $setDependency = null) {
    if (true === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value | self::FLAG_PUSH_ENABLED);
    }
    elseif (false === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value & ~self::FLAG_PUSH_ENABLED);
    }
    if (true === $setDependency) {
      $this
        ->set('flags', $this
        ->get('flags')->value | self::FLAG_DEPENDENCY_PUSH_ENABLED);
    }
    elseif (false === $setDependency) {
      $this
        ->set('flags', $this
        ->get('flags')->value & ~self::FLAG_DEPENDENCY_PUSH_ENABLED);
    }
    return (bool) ($this
      ->get('flags')->value & (self::FLAG_PUSH_ENABLED | self::FLAG_DEPENDENCY_PUSH_ENABLED));
  }

  /**
   * Returns the information if the entity has been chosen by the user to
   * be pushed with this flow and pool.
   *
   * @return bool
   */
  public function isManualPushEnabled() {
    return (bool) ($this
      ->get('flags')->value & self::FLAG_PUSH_ENABLED);
  }

  /**
   * Returns the information if the entity has been pushed with this flow and
   * pool as a dependency.
   *
   * @return bool
   */
  public function isPushedAsDependency() {
    return (bool) ($this
      ->get('flags')->value & self::FLAG_DEPENDENCY_PUSH_ENABLED);
  }

  /**
   * Returns the information if the user override the entity locally.
   *
   * @param bool $set
   *                         Optional parameter to set the value for EditOverride
   * @param bool $individual
   *
   * @return bool
   */
  public function isOverriddenLocally($set = null, $individual = false) {
    $status = EntityStatus::getInfosForEntity($this
      ->getEntityTypeName(), $this
      ->getUuid());
    if (true === $set) {
      if ($individual) {
        $this
          ->set('flags', $this
          ->get('flags')->value | self::FLAG_EDIT_OVERRIDE);
      }
      else {
        foreach ($status as $info) {
          $info
            ->isOverriddenLocally(true, true);
        }
      }
      return true;
    }
    if (false === $set) {
      if ($individual) {
        $this
          ->set('flags', $this
          ->get('flags')->value & ~self::FLAG_EDIT_OVERRIDE);
      }
      else {
        foreach ($status as $info) {
          $info
            ->isOverriddenLocally(false, true);
        }
      }
      return false;
    }
    if ($individual) {
      return (bool) ($this
        ->get('flags')->value & self::FLAG_EDIT_OVERRIDE);
    }
    foreach ($status as $info) {
      if ($info
        ->isOverriddenLocally(null, true)) {
        return true;
      }
    }
    return false;
  }

  /**
   * Returns the information if the entity has originally been created on this
   * site.
   *
   * @param bool  $set
   *                          Optional parameter to set the value for IsSourceEntity
   * @param mixed $individual
   *
   * @return bool
   */
  public function isSourceEntity($set = null, $individual = false) {
    $status = EntityStatus::getInfosForEntity($this
      ->getEntityTypeName(), $this
      ->getUuid());
    if (true === $set) {
      if ($individual) {
        $this
          ->set('flags', $this
          ->get('flags')->value | self::FLAG_IS_SOURCE_ENTITY);
      }
      else {
        foreach ($status as $info) {
          $info
            ->isSourceEntity(true, true);
        }
        $this
          ->isSourceEntity(true, true);
      }
      return true;
    }
    if (false === $set) {
      if ($individual) {
        $this
          ->set('flags', $this
          ->get('flags')->value & ~self::FLAG_IS_SOURCE_ENTITY);
      }
      else {
        foreach ($status as $info) {
          $info
            ->isSourceEntity(false, true);
        }
        $this
          ->isSourceEntity(false, true);
      }
      return false;
    }
    if ($individual) {
      return (bool) ($this
        ->get('flags')->value & self::FLAG_IS_SOURCE_ENTITY);
    }
    foreach ($status as $info) {
      if ($info
        ->isSourceEntity(null, true)) {
        return true;
      }
    }
    return $this
      ->isSourceEntity(null, true);
  }

  /**
   * Returns the information if the user allowed the push.
   *
   * @param bool $set
   *                  Optional parameter to set the value for UserEnabledPush
   *
   * @return bool
   */
  public function didUserEnablePush($set = null) {
    if (true === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value | self::FLAG_USER_ENABLED_PUSH);
    }
    elseif (false === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value & ~self::FLAG_USER_ENABLED_PUSH);
    }
    return (bool) ($this
      ->get('flags')->value & self::FLAG_USER_ENABLED_PUSH);
  }

  /**
   * Returns the information if the entity is deleted.
   *
   * @param bool $set
   *                  Optional parameter to set the value for Deleted
   *
   * @return bool
   */
  public function isDeleted($set = null) {
    if (true === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value | self::FLAG_DELETED);
    }
    elseif (false === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value & ~self::FLAG_DELETED);
    }
    return (bool) ($this
      ->get('flags')->value & self::FLAG_DELETED);
  }

  /**
   * Returns whether the entity was pushed embedded into another parent entity.
   * This is always done for field collections but can also be enabled for other
   * entities like paragraphs or media entities. This can save a lot of requests
   * when entities aren't all syndicated individually.
   *
   * @param bool $set
   *                  Optional parameter to set the value for the flag
   *
   * @return bool
   */
  public function wasPushedEmbedded($set = null) {
    if (true === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value | self::FLAG_PUSHED_EMBEDDED);
    }
    elseif (false === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value & ~self::FLAG_PUSHED_EMBEDDED);
    }
    return (bool) ($this
      ->get('flags')->value & self::FLAG_PUSHED_EMBEDDED);
  }

  /**
   * Returns whether the entity was pulled embedded in another parent entity.
   * This is always done for field collections but can also be enabled for other
   * entities like paragraphs or media entities. This can save a lot of requests
   * when entities aren't all syndicated individually.
   *
   * @param bool $set
   *                  Optional parameter to set the value for the flag
   *
   * @return bool
   */
  public function wasPulledEmbedded($set = null) {
    if (true === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value | self::FLAG_PULLED_EMBEDDED);
    }
    elseif (false === $set) {
      $this
        ->set('flags', $this
        ->get('flags')->value & ~self::FLAG_PULLED_EMBEDDED);
    }
    return (bool) ($this
      ->get('flags')->value & self::FLAG_PULLED_EMBEDDED);
  }

  /**
   * 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 also required to reset e.g. embedded paragraphs after the
   * "Overwrite content locally" checkbox is unchecked.
   *
   * @param string $type
   * @param string $uuid
   */
  public function setParentEntity($type, $uuid) {
    $this
      ->setData(self::DATA_PARENT_ENTITY, [
      'type' => $type,
      'uuid' => $uuid,
    ]);
  }

  /**
   * See above.
   *
   * @return null|\Drupal\Core\Entity\EntityInterface
   */
  public function getParentEntity() {
    $parent = $this
      ->getData(self::DATA_PARENT_ENTITY);
    if ($parent) {
      $matches = \Drupal::entityTypeManager()
        ->getStorage($parent['type'])
        ->loadByProperties([
        'uuid' => $parent['uuid'],
      ]);
      if (!count($matches)) {
        return null;
      }
      return reset($matches);
    }
    return null;
  }

  /**
   * Returns the timestamp for the last pull.
   *
   * @return int
   */
  public function getLastPull() {
    return $this
      ->get('last_import')->value;
  }

  /**
   * Set the last pull timestamp.
   *
   * @param int $timestamp
   */
  public function setLastPull($timestamp) {
    if ($this
      ->getLastPull() == $timestamp) {
      return;
    }
    $this
      ->set('last_import', $timestamp);

    // As this pull was successful, we can now reset the flags for status entity resets and failed pulls.
    if (!empty($timestamp)) {
      $this
        ->wasLastPullReset(false);
      $this
        ->didPullFail(false);

      // Delete status entities without Flow assigned- they're no longer needed.
      $error_entities = EntityStatus::getInfosForEntity($this
        ->getEntityTypeName(), $this
        ->getUuid(), [
        'flow' => self::FLOW_NO_FLOW,
      ], true);
      foreach ($error_entities as $entity) {
        $entity
          ->delete();
      }
    }
    else {
      $this
        ->wasLastPullReset(true);
    }
  }

  /**
   * Returns the UUID of the entity this information belongs to.
   *
   * @return string
   */
  public function getUuid() {
    return $this
      ->get('entity_uuid')->value;
  }

  /**
   * Returns the entity type name of the entity this information belongs to.
   *
   * @return string
   */
  public function getEntityTypeName() {
    return $this
      ->get('entity_type')->value;
  }

  /**
   * Returns the timestamp for the last push.
   *
   * @return int
   */
  public function getLastPush() {
    return $this
      ->get('last_export')->value;
  }

  /**
   * Set the last pull timestamp.
   *
   * @param int $timestamp
   */
  public function setLastPush($timestamp) {
    if ($this
      ->getLastPush() == $timestamp) {
      return;
    }
    $this
      ->set('last_export', $timestamp);

    // As this push was successful, we can now reset the flags for status entity resets and failed exports.
    if (!empty($timestamp)) {
      $this
        ->wasLastPushReset(false);
      $this
        ->didPushFail(false);
    }
    else {
      $this
        ->wasLastPushReset(true);
    }
  }

  /**
   * Get the flow.
   *
   * @return Flow
   */
  public function getFlow() {
    if (empty($this
      ->get('flow')->value)) {
      return null;
    }
    $flows = Flow::getAll();
    if (empty($flows[$this
      ->get('flow')->value])) {
      return null;
    }
    return $flows[$this
      ->get('flow')->value];
  }

  /**
   * Get the pool.
   *
   * @return Pool
   */
  public function getPool() {
    return Pool::getAll()[$this
      ->get('pool')->value];
  }

  /**
   * Returns the entity type version.
   *
   * @return string
   */
  public function getEntityTypeVersion() {
    return $this
      ->get('entity_type_version')->value;
  }

  /**
   * Set the last pull timestamp.
   *
   * @param string $version
   */
  public function setEntityTypeVersion($version) {
    $this
      ->set('entity_type_version', $version);
  }

  /**
   * Returns the entities source url.
   *
   * @return string
   */
  public function getSourceUrl() {
    return $this
      ->get('source_url')->value;
  }

  /**
   * Get a previously saved key=>value pair.
   *
   * @see self::setData()
   *
   * @param null|string|string[] $key
   *                                  The key to retrieve
   *
   * @return mixed whatever you previously stored here or NULL if the key
   *               doesn't exist
   */
  public function getData($key = null) {
    $data = $this
      ->get('data')
      ->getValue();
    if (empty($data)) {
      return null;
    }
    $storage =& $data[0];
    if (empty($key)) {
      return $data;
    }
    if (!is_array($key)) {
      $key = [
        $key,
      ];
    }
    foreach ($key as $index) {
      if (!isset($storage[$index])) {
        return null;
      }
      $storage =& $storage[$index];
    }
    return $storage;
  }

  /**
   * Set a key=>value pair.
   *
   * @param string|string[] $key
   *                               The key to set (for hierarchical usage, provide
   *                               an array of indices
   * @param mixed           $value
   *                               The value to set. Must be a valid value for Drupal's
   *                               "map" storage (so basic types that can be serialized).
   */
  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);
  }

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['flow'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Flow'))
      ->setDescription(t('The flow the status entity is based on.'));
    $fields['pool'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Pool'))
      ->setDescription(t('The pool the entity is connected to.'));
    $fields['entity_uuid'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Entity UUID'))
      ->setDescription(t('The UUID of the entity that is synchronized.'))
      ->setSetting('max_length', 128);
    $fields['entity_type'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Entity type'))
      ->setDescription(t('The entity type of the entity that is synchronized.'));
    $fields['entity_type_version'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Entity type version'))
      ->setDescription(t('The version of the entity type provided by Content Sync.'))
      ->setSetting('max_length', 32);
    $fields['source_url'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Source URL'))
      ->setDescription(t('The entities source URL.'))
      ->setRequired(false);
    $fields['last_export'] = BaseFieldDefinition::create('timestamp')
      ->setLabel(t('Last pushed'))
      ->setDescription(t('The last time the entity got pushed.'))
      ->setRequired(false);
    $fields['last_import'] = BaseFieldDefinition::create('timestamp')
      ->setLabel(t('Last pulled'))
      ->setDescription(t('The last time the entity got pulled.'))
      ->setRequired(false);
    $fields['flags'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Flags'))
      ->setDescription(t('Stores boolean information about the pushed/pulled entity.'))
      ->setSetting('unsigned', true)
      ->setDefaultValue(0);
    $fields['data'] = BaseFieldDefinition::create('map')
      ->setLabel(t('Data'))
      ->setDescription(t('Stores further information about the pushed/pulled entity that can also be used by entity and field handlers.'))
      ->setRequired(false);
    return $fields;
  }

  /**
   * @return null|string
   */
  public function getEntityPushHash() {
    return $this
      ->getData(self::DATA_ENTITY_PUSH_HASH);
  }

  /**
   * @param string $hash
   */
  public function setEntityPushHash($hash) {
    $this
      ->setData(self::DATA_ENTITY_PUSH_HASH, $hash);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
ContentEntityBase::$activeLangcode protected property Language code identifying the entity active language.
ContentEntityBase::$defaultLangcode protected property Local cache for the default language code.
ContentEntityBase::$defaultLangcodeKey protected property The default langcode entity key.
ContentEntityBase::$enforceRevisionTranslationAffected protected property Whether the revision translation affected flag has been enforced.
ContentEntityBase::$entityKeys protected property Holds untranslatable entity keys such as the ID, bundle, and revision ID.
ContentEntityBase::$fieldDefinitions protected property Local cache for field definitions.
ContentEntityBase::$fields protected property The array of fields, each being an instance of FieldItemListInterface.
ContentEntityBase::$fieldsToSkipFromTranslationChangesCheck protected static property Local cache for fields to skip from the checking for translation changes.
ContentEntityBase::$isDefaultRevision protected property Indicates whether this is the default revision.
ContentEntityBase::$langcodeKey protected property The language entity key.
ContentEntityBase::$languages protected property Local cache for the available language objects.
ContentEntityBase::$loadedRevisionId protected property The loaded revision ID before the new revision was set.
ContentEntityBase::$newRevision protected property Boolean indicating whether a new revision should be created on save.
ContentEntityBase::$revisionTranslationAffectedKey protected property The revision translation affected entity key.
ContentEntityBase::$translatableEntityKeys protected property Holds translatable entity keys such as the label.
ContentEntityBase::$translationInitialize protected property A flag indicating whether a translation object is being initialized.
ContentEntityBase::$translations protected property An array of entity translation metadata.
ContentEntityBase::$validated protected property Whether entity validation was performed.
ContentEntityBase::$validationRequired protected property Whether entity validation is required before saving the entity.
ContentEntityBase::$values protected property The plain data values of the contained fields.
ContentEntityBase::access public function Checks data value access. Overrides EntityBase::access 1
ContentEntityBase::addTranslation public function Adds a new translation to the translatable object. Overrides TranslatableInterface::addTranslation
ContentEntityBase::bundle public function Gets the bundle of the entity. Overrides EntityBase::bundle
ContentEntityBase::bundleFieldDefinitions public static function Provides field definitions for a specific bundle. Overrides FieldableEntityInterface::bundleFieldDefinitions 4
ContentEntityBase::clearTranslationCache protected function Clear entity translation object cache to remove stale references.
ContentEntityBase::createDuplicate public function Creates a duplicate of the entity. Overrides EntityBase::createDuplicate 1
ContentEntityBase::get public function Gets a field item list. Overrides FieldableEntityInterface::get
ContentEntityBase::getEntityKey protected function Gets the value of the given entity key, if defined. 1
ContentEntityBase::getFieldDefinition public function Gets the definition of a contained field. Overrides FieldableEntityInterface::getFieldDefinition
ContentEntityBase::getFieldDefinitions public function Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface::getFieldDefinitions
ContentEntityBase::getFields public function Gets an array of all field item lists. Overrides FieldableEntityInterface::getFields
ContentEntityBase::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip in ::hasTranslationChanges. 1
ContentEntityBase::getIterator public function
ContentEntityBase::getLanguages protected function
ContentEntityBase::getLoadedRevisionId public function Gets the loaded Revision ID of the entity. Overrides RevisionableInterface::getLoadedRevisionId
ContentEntityBase::getRevisionId public function Gets the revision identifier of the entity. Overrides RevisionableInterface::getRevisionId
ContentEntityBase::getTranslatableFields public function Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface::getTranslatableFields
ContentEntityBase::getTranslatedField protected function Gets a translated field.
ContentEntityBase::getTranslation public function Gets a translation of the data. Overrides TranslatableInterface::getTranslation
ContentEntityBase::getTranslationLanguages public function Returns the languages the data is translated to. Overrides TranslatableInterface::getTranslationLanguages
ContentEntityBase::getTranslationStatus public function Returns the translation status. Overrides TranslationStatusInterface::getTranslationStatus
ContentEntityBase::getUntranslated public function Returns the translatable object referring to the original language. Overrides TranslatableInterface::getUntranslated
ContentEntityBase::hasField public function Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface::hasField
ContentEntityBase::hasTranslation public function Checks there is a translation for the given language code. Overrides TranslatableInterface::hasTranslation
ContentEntityBase::hasTranslationChanges public function Determines if the current translation of the entity has unsaved changes. Overrides TranslatableInterface::hasTranslationChanges
ContentEntityBase::id public function Gets the identifier. Overrides EntityBase::id
ContentEntityBase::initializeTranslation protected function Instantiates a translation object for an existing translation.
ContentEntityBase::isDefaultRevision public function Checks if this entity is the default revision. Overrides RevisionableInterface::isDefaultRevision
ContentEntityBase::isDefaultTranslation public function Checks whether the translation is the default one. Overrides TranslatableInterface::isDefaultTranslation
ContentEntityBase::isDefaultTranslationAffectedOnly public function Checks if untranslatable fields should affect only the default translation. Overrides TranslatableRevisionableInterface::isDefaultTranslationAffectedOnly
ContentEntityBase::isLatestRevision public function Checks if this entity is the latest revision. Overrides RevisionableInterface::isLatestRevision
ContentEntityBase::isLatestTranslationAffectedRevision public function Checks whether this is the latest revision affecting this translation. Overrides TranslatableRevisionableInterface::isLatestTranslationAffectedRevision
ContentEntityBase::isNewRevision public function Determines whether a new revision should be created on save. Overrides RevisionableInterface::isNewRevision
ContentEntityBase::isNewTranslation public function Checks whether the translation is new. Overrides TranslatableInterface::isNewTranslation
ContentEntityBase::isRevisionTranslationAffected public function Checks whether the current translation is affected by the current revision. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffected
ContentEntityBase::isRevisionTranslationAffectedEnforced public function Checks if the revision translation affected flag value has been enforced. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffectedEnforced
ContentEntityBase::isTranslatable public function Returns the translation support status. Overrides TranslatableInterface::isTranslatable
ContentEntityBase::isValidationRequired public function Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::isValidationRequired
ContentEntityBase::label public function Gets the label of the entity. Overrides EntityBase::label 2
ContentEntityBase::language public function Gets the language of the entity. Overrides EntityBase::language
ContentEntityBase::onChange public function Reacts to changes to a field. Overrides FieldableEntityInterface::onChange
ContentEntityBase::postCreate public function Acts on a created entity before hooks are invoked. Overrides EntityBase::postCreate
ContentEntityBase::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides EntityBase::postSave 5
ContentEntityBase::preSave public function Acts on an entity before the presave hook is invoked. Overrides EntityBase::preSave 5
ContentEntityBase::preSaveRevision public function Acts on a revision before it gets saved. Overrides RevisionableInterface::preSaveRevision 2
ContentEntityBase::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityBase::referencedEntities 1
ContentEntityBase::removeTranslation public function Removes the translation identified by the given language code. Overrides TranslatableInterface::removeTranslation
ContentEntityBase::set public function Sets a field value. Overrides FieldableEntityInterface::set
ContentEntityBase::setDefaultLangcode protected function Populates the local cache for the default language code.
ContentEntityBase::setNewRevision public function Enforces an entity to be saved as a new revision. Overrides RevisionableInterface::setNewRevision
ContentEntityBase::setRevisionTranslationAffected public function Marks the current revision translation as affected. Overrides TranslatableRevisionableInterface::setRevisionTranslationAffected
ContentEntityBase::setRevisionTranslationAffectedEnforced public function Enforces the revision translation affected flag value. Overrides TranslatableRevisionableInterface::setRevisionTranslationAffectedEnforced
ContentEntityBase::setValidationRequired public function Sets whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::setValidationRequired
ContentEntityBase::toArray public function Gets an array of all property values. Overrides EntityBase::toArray
ContentEntityBase::updateFieldLangcodes protected function Updates language for already instantiated fields.
ContentEntityBase::updateLoadedRevisionId public function Updates the loaded Revision ID with the revision ID. Overrides RevisionableInterface::updateLoadedRevisionId
ContentEntityBase::updateOriginalValues public function Updates the original values with the interim changes.
ContentEntityBase::uuid public function Gets the entity UUID (Universally Unique Identifier). Overrides EntityBase::uuid
ContentEntityBase::validate public function Validates the currently set values. Overrides FieldableEntityInterface::validate
ContentEntityBase::wasDefaultRevision public function Checks whether the entity object was a default revision when it was saved. Overrides RevisionableInterface::wasDefaultRevision
ContentEntityBase::__clone public function Magic method: Implements a deep clone.
ContentEntityBase::__construct public function Constructs an Entity object. Overrides EntityBase::__construct
ContentEntityBase::__get public function Implements the magic method for getting object properties.
ContentEntityBase::__isset public function Implements the magic method for isset().
ContentEntityBase::__set public function Implements the magic method for setting object properties.
ContentEntityBase::__sleep public function Overrides EntityBase::__sleep
ContentEntityBase::__unset public function Implements the magic method for unset().
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 1
DependencySerializationTrait::__wakeup public function 2
EntityBase::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
EntityBase::$entityTypeId protected property The entity type.
EntityBase::$typedData protected property A typed data object wrapping this entity.
EntityBase::create public static function Constructs a new entity object, without permanently saving it. Overrides EntityInterface::create
EntityBase::delete public function Deletes an entity permanently. Overrides EntityInterface::delete 2
EntityBase::enforceIsNew public function Enforces an entity to be new. Overrides EntityInterface::enforceIsNew
EntityBase::entityManager Deprecated protected function Gets the entity manager.
EntityBase::entityTypeBundleInfo protected function Gets the entity type bundle info service.
EntityBase::entityTypeManager protected function Gets the entity type manager.
EntityBase::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
EntityBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
EntityBase::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags
EntityBase::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface::getCacheTagsToInvalidate 2
EntityBase::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. Overrides EntityInterface::getConfigDependencyKey
EntityBase::getConfigDependencyName public function Gets the configuration dependency name. Overrides EntityInterface::getConfigDependencyName 1
EntityBase::getConfigTarget public function Gets the configuration target identifier for the entity. Overrides EntityInterface::getConfigTarget 1
EntityBase::getEntityType public function Gets the entity type definition. Overrides EntityInterface::getEntityType
EntityBase::getEntityTypeId public function Gets the ID of the type of the entity. Overrides EntityInterface::getEntityTypeId
EntityBase::getListCacheTagsToInvalidate protected function The list cache tags to invalidate for this entity.
EntityBase::getOriginalId public function Gets the original ID. Overrides EntityInterface::getOriginalId 1
EntityBase::getTypedData public function Gets a typed data object for this entity object. Overrides EntityInterface::getTypedData
EntityBase::hasLinkTemplate public function Indicates if a link template exists for a given key. Overrides EntityInterface::hasLinkTemplate
EntityBase::invalidateTagsOnDelete protected static function Invalidates an entity's cache tags upon delete. 1
EntityBase::invalidateTagsOnSave protected function Invalidates an entity's cache tags upon save. 1
EntityBase::isNew public function Determines whether the entity is new. Overrides EntityInterface::isNew 2
EntityBase::languageManager protected function Gets the language manager.
EntityBase::link public function Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface::link 1
EntityBase::linkTemplates protected function Gets an array link templates. 1
EntityBase::load public static function Loads an entity. Overrides EntityInterface::load
EntityBase::loadMultiple public static function Loads one or more entities. Overrides EntityInterface::loadMultiple
EntityBase::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface::postDelete 16
EntityBase::postLoad public static function Acts on loaded entities. Overrides EntityInterface::postLoad 2
EntityBase::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides EntityInterface::preDelete 4
EntityBase::save public function Saves an entity permanently. Overrides EntityInterface::save 3
EntityBase::setOriginalId public function Sets the original ID. Overrides EntityInterface::setOriginalId 1
EntityBase::toLink public function Generates the HTML for a link to this entity. Overrides EntityInterface::toLink
EntityBase::toUrl public function Gets the URL object for the entity. Overrides EntityInterface::toUrl 2
EntityBase::uriRelationships public function Gets a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
EntityBase::url public function Gets the public URL for this entity. Overrides EntityInterface::url 2
EntityBase::urlInfo public function Gets the URL object for the entity. Overrides EntityInterface::urlInfo 1
EntityBase::urlRouteParameters protected function Gets an array of placeholders for this entity. 2
EntityBase::uuidGenerator protected function Gets the UUID generator.
EntityChangedTrait::getChangedTime public function Gets the timestamp of the last entity change for the current translation.
EntityChangedTrait::getChangedTimeAcrossTranslations public function Returns the timestamp of the last entity change across all translations.
EntityChangedTrait::setChangedTime public function Sets the timestamp of the last entity change for the current translation.
EntityChangesDetectionTrait::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip when checking for changes. Aliased as: traitGetFieldsToSkipFromTranslationChangesCheck
EntityStatus::accessTemporaryPushToPoolInfoForField public static function
EntityStatus::baseFieldDefinitions public static function Provides base field definitions for an entity type. Overrides ContentEntityBase::baseFieldDefinitions
EntityStatus::DATA_ENTITY_PUSH_HASH public constant
EntityStatus::DATA_PARENT_ENTITY public constant
EntityStatus::DATA_PULL_FAILURE public constant
EntityStatus::DATA_PUSH_FAILURE public constant
EntityStatus::didPullFail public function Returns the information if the last pull of the entity failed.
EntityStatus::didPushFail public function Returns the information if the last push of the entity failed.
EntityStatus::didUserEnablePush public function Returns the information if the user allowed the push.
EntityStatus::FLAG_DELETED public constant
EntityStatus::FLAG_DEPENDENCY_PUSH_ENABLED public constant
EntityStatus::FLAG_EDIT_OVERRIDE public constant
EntityStatus::FLAG_IS_SOURCE_ENTITY public constant
EntityStatus::FLAG_LAST_PULL_RESET public constant
EntityStatus::FLAG_LAST_PUSH_RESET public constant
EntityStatus::FLAG_PULLED_EMBEDDED public constant
EntityStatus::FLAG_PULL_FAILED public constant
EntityStatus::FLAG_PULL_FAILED_SOFT public constant
EntityStatus::FLAG_PUSHED_EMBEDDED public constant
EntityStatus::FLAG_PUSH_ENABLED public constant
EntityStatus::FLAG_PUSH_FAILED public constant
EntityStatus::FLAG_PUSH_FAILED_SOFT public constant
EntityStatus::FLAG_UNUSED_CLONED public constant
EntityStatus::FLAG_USER_ENABLED_PUSH public constant
EntityStatus::FLOW_NO_FLOW public constant
EntityStatus::getData public function Get a previously saved key=>value pair.
EntityStatus::getEntity public function Get the entity this entity status belongs to.
EntityStatus::getEntityPushHash public function
EntityStatus::getEntityTypeName public function Returns the entity type name of the entity this information belongs to.
EntityStatus::getEntityTypeVersion public function Returns the entity type version.
EntityStatus::getFlow public function Get the flow.
EntityStatus::getInfoForEntity public static function
EntityStatus::getInfoForPool public static function
EntityStatus::getInfosForEntity public static function Get a list of all entity status entities for the given entity.
EntityStatus::getLastPull public function Returns the timestamp for the last pull.
EntityStatus::getLastPullForEntity public static function
EntityStatus::getLastPush public function Returns the timestamp for the last push.
EntityStatus::getLastPushForEntity public static function
EntityStatus::getParentEntity public function See above.
EntityStatus::getPool public function Get the pool.
EntityStatus::getSourceUrl public function Returns the entities source url.
EntityStatus::getUuid public function Returns the UUID of the entity this information belongs to.
EntityStatus::isDeleted public function Returns the information if the entity is deleted.
EntityStatus::isManualPushEnabled public function Returns the information if the entity has been chosen by the user to be pushed with this flow and pool.
EntityStatus::isOverriddenLocally public function Returns the information if the user override the entity locally.
EntityStatus::isPushedAsDependency public function Returns the information if the entity has been pushed with this flow and pool as a dependency.
EntityStatus::isPushEnabled public function Returns the information if the entity has been chosen by the user to be pushed with this flow and pool.
EntityStatus::isSourceEntity public function Returns the information if the entity has originally been created on this site.
EntityStatus::preCreate public static function Changes the values of an entity before it is created. Overrides EntityBase::preCreate
EntityStatus::resetStatus public function
EntityStatus::saveSelectedPoolsToPushTo public static function
EntityStatus::saveSelectedPushToPoolForField public static function
EntityStatus::setData public function Set a key=>value pair.
EntityStatus::setEntityPushHash public function
EntityStatus::setEntityTypeVersion public function Set the last pull timestamp.
EntityStatus::setLastPull public function Set the last pull timestamp.
EntityStatus::setLastPush public function Set the last pull timestamp.
EntityStatus::setParentEntity public function 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…
EntityStatus::wasLastPullReset public function Returns the information if the entity has been pulled before but the last import date was reset.
EntityStatus::wasLastPushReset public function Returns the information if the entity has been pushed before but the last push date was reset.
EntityStatus::wasPulledEmbedded public function Returns whether the entity was pulled embedded in another parent entity. This is always done for field collections but can also be enabled for other entities like paragraphs or media entities. This can save a lot of requests when entities aren't…
EntityStatus::wasPushedEmbedded public function Returns whether the entity was pushed embedded into another parent entity. This is always done for field collections but can also be enabled for other entities like paragraphs or media entities. This can save a lot of requests when entities…
EntityStatus::whyDidPullingFail public function Get the details provided to ->didPullFail( TRUE, ... ) before.
EntityStatus::whyDidPushingFail public function Get the details provided to ->didPushFail( TRUE, ... ) before.
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
SynchronizableEntityTrait::$isSyncing protected property Whether this entity is being created, updated or deleted through a synchronization process.
SynchronizableEntityTrait::isSyncing public function
SynchronizableEntityTrait::setSyncing public function
TranslationStatusInterface::TRANSLATION_CREATED constant Status code identifying a newly created translation.
TranslationStatusInterface::TRANSLATION_EXISTING constant Status code identifying an existing translation.
TranslationStatusInterface::TRANSLATION_REMOVED constant Status code identifying a removed translation.