class JobItem in Translation Management Tool 8
Entity class for the tmgmt_job_item entity.
Plugin annotation
@ContentEntityType(
  id = "tmgmt_job_item",
  label = @Translation("Translation Job Item"),
  module = "tmgmt",
  handlers = {
    "access" = "Drupal\tmgmt\Entity\Controller\JobItemAccessControlHandler",
    "form" = {
      "edit" = "Drupal\tmgmt\Form\JobItemForm",
      "abort" = "Drupal\tmgmt\Form\JobItemAbortForm",
      "delete" = "Drupal\tmgmt\Form\JobItemDeleteForm"
    },
    "list_builder" = "Drupal\tmgmt\Entity\ListBuilder\JobItemListBuilder",
    "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
    "views_data" = "Drupal\tmgmt\Entity\ViewsData\JobItemViewsData"
  },
  base_table = "tmgmt_job_item",
  entity_keys = {
    "id" = "tjiid",
    "uuid" = "uuid"
  },
  links = {
    "canonical" = "/admin/tmgmt/items/{tmgmt_job_item}",
    "abort-form" = "/admin/tmgmt/items/{tmgmt_job_item}/abort",
    "delete-form" = "/admin/tmgmt/items/{tmgmt_job_item}/delete",
  },
)
Hierarchy
- class \Drupal\Core\Entity\EntityBase implements EntityInterface uses RefinableCacheableDependencyTrait, DependencySerializationTrait- class \Drupal\Core\Entity\ContentEntityBase implements \Drupal\Core\Entity\IteratorAggregate, ContentEntityInterface, TranslationStatusInterface uses EntityChangesDetectionTrait, SynchronizableEntityTrait- class \Drupal\tmgmt\Entity\JobItem implements JobItemInterface
 
 
- class \Drupal\Core\Entity\ContentEntityBase implements \Drupal\Core\Entity\IteratorAggregate, ContentEntityInterface, TranslationStatusInterface uses EntityChangesDetectionTrait, SynchronizableEntityTrait
Expanded class hierarchy of JobItem
Related topics
19 files declare their use of JobItem
- CartForm.php in src/Form/ CartForm.php 
- ConfigSourceListTest.php in sources/tmgmt_config/ tests/ src/ Functional/ ConfigSourceListTest.php 
- ConfigTranslateForm.php in sources/tmgmt_config/ src/ Form/ ConfigTranslateForm.php 
- ContentTmgmtEntitySourceListTest.php in sources/content/ tests/ src/ Functional/ ContentTmgmtEntitySourceListTest.php 
- ContentTranslateForm.php in sources/content/ src/ Form/ ContentTranslateForm.php 
File
- src/Entity/ JobItem.php, line 54 
Namespace
Drupal\tmgmt\EntityView source
class JobItem extends ContentEntityBase implements JobItemInterface {
  /**
   * Holds the unserialized source data.
   *
   * @var array
   */
  protected $unserializedData;
  /**
   * Statically cached state definitions.
   *
   * @var
   */
  protected static $stateDefinitions;
  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields['tjiid'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Job Item ID'))
      ->setDescription(t('The Job Item ID.'))
      ->setReadOnly(TRUE)
      ->setSetting('unsigned', TRUE);
    $fields['tjid'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Job'))
      ->setDescription(t('The Job.'))
      ->setReadOnly(TRUE)
      ->setSetting('target_type', 'tmgmt_job')
      ->setDefaultValue(0);
    $fields['uuid'] = BaseFieldDefinition::create('uuid')
      ->setLabel(t('UUID'))
      ->setDescription(t('The job item UUID.'))
      ->setReadOnly(TRUE);
    $fields['plugin'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Plugin'))
      ->setDescription(t('The plugin of this job item.'))
      ->setSettings(array(
      'max_length' => 255,
    ));
    $fields['item_type'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Item Type'))
      ->setDescription(t('The item type of this job item.'))
      ->setSettings(array(
      'max_length' => 255,
    ));
    $fields['item_id'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Item ID'))
      ->setDescription(t('The item ID of this job item.'))
      ->setSettings(array(
      'max_length' => 255,
    ));
    $fields['data'] = BaseFieldDefinition::create('string_long')
      ->setLabel(t('Data'))
      ->setDescription(t('The source data'));
    $states = static::getStates();
    $fields['state'] = BaseFieldDefinition::create('list_integer')
      ->setLabel(t('Job item state'))
      ->setDescription(t('The job item state'))
      ->setSetting('allowed_values', $states)
      ->setDefaultValue(static::STATE_INACTIVE);
    $fields['translator_state'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Translator job item state'));
    $fields['changed'] = BaseFieldDefinition::create('changed')
      ->setLabel(t('Changed'))
      ->setDescription(t('The time that the job was last edited.'));
    $fields['count_pending'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Pending count'))
      ->setSetting('unsigned', TRUE);
    $fields['count_translated'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Translated count'))
      ->setSetting('unsigned', TRUE);
    $fields['count_reviewed'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Reviewed count'))
      ->setSetting('unsigned', TRUE);
    $fields['count_accepted'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Accepted count'))
      ->setSetting('unsigned', TRUE);
    $fields['word_count'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Word count'))
      ->setSetting('unsigned', TRUE);
    $fields['tags_count'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Tags count'))
      ->setSetting('unsigned', TRUE);
    return $fields;
  }
  /**
   * {@inheritdoc}
   */
  public function cloneAsActive() {
    $clone = $this
      ->createDuplicate();
    $clone->data->value = NULL;
    $clone->unserializedData = NULL;
    $clone->tjid->target_id = 0;
    $clone->tjiid->value = 0;
    $clone->word_count->value = NULL;
    $clone->tags_count->value = NULL;
    $clone->count_accepted->value = NULL;
    $clone->count_pending->value = NULL;
    $clone->count_translated->value = NULL;
    $clone->count_reviewed->value = NULL;
    $clone->state->value = static::STATE_ACTIVE;
    return $clone;
  }
  /**
   * {@inheritdoc}
   */
  public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);
    if ($this
      ->getJobId()) {
      $this
        ->recalculateStatistics();
      drupal_static_reset('tmgmt_job_statistics_load');
    }
    if ($this->unserializedData) {
      $this->data = Json::encode($this->unserializedData);
    }
    elseif (empty($this
      ->get('data')->value)) {
      $this->data = Json::encode(array());
    }
  }
  /**
   * {@inheritdoc}
   */
  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    // We need to check whether the state of the job is affected by this
    // deletion.
    foreach ($entities as $entity) {
      if ($job = $entity
        ->getJob()) {
        // We only care for active jobs.
        if ($job
          ->isActive() && tmgmt_job_check_finished($job
          ->id())) {
          // Mark the job as finished.
          $job
            ->finished();
        }
      }
    }
    parent::preDelete($storage, $entities);
  }
  /**
   * {@inheritdoc}
   */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage, $entities);
    $entity_type_manager = \Drupal::entityTypeManager();
    // Since we are deleting one or multiple job items here we also need to
    // delete the attached messages.
    $mids = \Drupal::entityQuery('tmgmt_message')
      ->condition('tjiid', array_keys($entities), 'IN')
      ->execute();
    if (!empty($mids)) {
      $messages = $entity_type_manager
        ->getStorage('tmgmt_message')
        ->loadMultiple($mids);
      $entity_type_manager
        ->getStorage('tmgmt_message')
        ->delete($messages);
    }
    $trids = \Drupal::entityQuery('tmgmt_remote')
      ->condition('tjiid', array_keys($entities), 'IN')
      ->execute();
    if (!empty($trids)) {
      $remotes = $entity_type_manager
        ->getStorage('tmgmt_remote')
        ->loadMultiple($trids);
      $entity_type_manager
        ->getStorage('tmgmt_remote')
        ->delete($remotes);
    }
  }
  /**
   * {@inheritdoc}
   */
  public function getJobId() {
    return $this
      ->get('tjid')->target_id;
  }
  /**
   * {@inheritdoc}
   */
  public function getPlugin() {
    return $this
      ->get('plugin')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function getItemType() {
    return $this
      ->get('item_type')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function getItemId() {
    return $this
      ->get('item_id')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function getChangedTime() {
    return $this
      ->get('changed')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function label($langcode = NULL) {
    $label = $this
      ->getSourceLabel() ?: parent::label();
    if (strlen($label) > Job::LABEL_MAX_LENGTH) {
      $label = Unicode::truncate($label, Job::LABEL_MAX_LENGTH, TRUE);
    }
    return $label;
  }
  /**
   * {@inheritdoc}
   */
  public function addMessage($message, $variables = array(), $type = 'status') {
    // Save the job item if it hasn't yet been saved.
    if (!$this
      ->isNew() || $this
      ->save()) {
      $message = tmgmt_message_create($message, $variables, array(
        'tjid' => $this
          ->getJobId(),
        'tjiid' => $this
          ->id(),
        'type' => $type,
      ));
      if ($message
        ->save()) {
        return $message;
      }
    }
  }
  /**
   * {@inheritdoc}
   */
  public function getSourceLabel() {
    if ($plugin = $this
      ->getSourcePlugin()) {
      return (string) $plugin
        ->getLabel($this);
    }
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function getSourceUrl() {
    if ($plugin = $this
      ->getSourcePlugin()) {
      return $plugin
        ->getUrl($this);
    }
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function getSourceType() {
    if ($plugin = $this
      ->getSourcePlugin()) {
      return $plugin
        ->getType($this);
    }
    return ucfirst($this
      ->get('item_type')->value);
  }
  /**
   * {@inheritdoc}
   */
  public function getJob() {
    return Job::load($this
      ->get('tjid')->target_id);
  }
  /**
   * {@inheritdoc}
   */
  public function getTranslator() {
    if ($this
      ->hasTranslator()) {
      return $this
        ->getJob()
        ->getTranslator();
    }
    return NULL;
  }
  /**
   * {@inheritdoc}
   */
  public function hasTranslator() {
    if ($this
      ->getJob() && $this
      ->getJob()
      ->hasTranslator()) {
      return TRUE;
    }
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function getTranslatorPlugin() {
    if ($job = $this
      ->getJob()) {
      return $job
        ->getTranslatorPlugin();
    }
    return NULL;
  }
  /**
   * {@inheritdoc}
   */
  public function getData($key = array(), $index = NULL) {
    $this
      ->decodeData();
    if (empty($this->unserializedData) && $this
      ->getJobId()) {
      // Load the data from the source if it has not been set yet.
      $this->unserializedData = $this
        ->getSourceData();
      $this
        ->save();
    }
    if (empty($key)) {
      return $this->unserializedData;
    }
    if ($index) {
      $key = array_merge($key, array(
        $index,
      ));
    }
    return NestedArray::getValue($this->unserializedData, $key);
  }
  /**
   * {@inheritdoc}
   */
  public function getSourceData() {
    if ($plugin = $this
      ->getSourcePlugin()) {
      $data = $plugin
        ->getData($this);
      /** @var \Drupal\tmgmt\SegmenterInterface $segmenter */
      $segmenter = \Drupal::service('tmgmt.segmenter');
      return $segmenter
        ->getSegmentedData($data);
    }
    return array();
  }
  /**
   * {@inheritdoc}
   */
  public function getSourcePlugin() {
    if ($this
      ->get('plugin')->value) {
      try {
        return \Drupal::service('plugin.manager.tmgmt.source')
          ->createInstance($this
          ->get('plugin')->value);
      } catch (PluginException $e) {
        // Ignore exceptions due to missing source plugins.
      }
    }
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function getCountPending() {
    return $this
      ->get('count_pending')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function getCountTranslated() {
    return $this
      ->get('count_translated')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function getCountAccepted() {
    return $this
      ->get('count_accepted')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function getCountReviewed() {
    return $this
      ->get('count_reviewed')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function getWordCount() {
    return (int) $this
      ->get('word_count')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function getTagsCount() {
    return (int) $this
      ->get('tags_count')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function needsReview($message = NULL, $variables = array(), $type = 'status') {
    if (!isset($message)) {
      $source_url = $this
        ->getSourceUrl();
      $message = $source_url ? 'The translation for <a href=":source_url">@source</a> needs to be reviewed.' : 'The translation for @source needs to be reviewed.';
      $variables = $source_url ? array(
        ':source_url' => $source_url,
        '@source' => $this
          ->getSourceLabel(),
      ) : array(
        '@source' => $this
          ->getSourceLabel(),
      );
    }
    $return = $this
      ->setState(static::STATE_REVIEW, $message, $variables, $type);
    // Auto accept the translation if the translator is configured for it.
    if ($this
      ->getTranslator()
      ->isAutoAccept() && !$this
      ->isAborted()) {
      try {
        $this
          ->acceptTranslation();
      } catch (\Exception $e) {
        $this
          ->addMessage('Failed to automatically accept translation, error: @error', [
          '@error' => $e
            ->getMessage(),
        ], 'error');
      }
    }
    return $return;
  }
  /**
   * {@inheritdoc}
   */
  public function accepted($message = NULL, $variables = array(), $type = 'status') {
    if (!isset($message)) {
      $source_url = $this
        ->getSourceUrl();
      try {
        // @todo: Make sure we use the latest revision.
        //   Fix in https://www.drupal.org/project/tmgmt/issues/2979126.
        $translation = \Drupal::entityTypeManager()
          ->getStorage($this
          ->getItemType())
          ->load($this
          ->getItemId());
      } catch (PluginNotFoundException $e) {
        $translation = NULL;
      }
      if (isset($translation) && $translation
        ->hasTranslation($this
        ->getJob()
        ->getTargetLangcode())) {
        $translation = $translation
          ->getTranslation($this
          ->getJob()
          ->getTargetLangcode());
        try {
          $translation_url = $translation
            ->toUrl();
        } catch (UndefinedLinkTemplateException $e) {
          $translation_url = NULL;
        }
        $message = $source_url && $translation_url ? 'The translation for <a href=":source_url">@source</a> has been accepted as <a href=":target_url">@target</a>.' : 'The translation for @source has been accepted as @target.';
        $variables = $source_url && $translation_url ? array(
          ':source_url' => $source_url
            ->toString(),
          '@source' => $this
            ->getSourceLabel(),
          ':target_url' => $translation_url
            ->toString(),
          '@target' => $translation ? $translation
            ->label() : $this
            ->getSourceLabel(),
        ) : array(
          '@source' => $this
            ->getSourceLabel(),
          '@target' => $translation ? $translation
            ->label() : $this
            ->getSourceLabel(),
        );
      }
      else {
        $message = $source_url ? 'The translation for <a href=":source_url">@source</a> has been accepted.' : 'The translation for @source has been accepted.';
        $variables = $source_url ? array(
          ':source_url' => $source_url
            ->toString(),
          '@source' => $this
            ->getSourceLabel(),
        ) : array(
          '@source' => $this
            ->getSourceLabel(),
        );
      }
    }
    $return = $this
      ->setState(static::STATE_ACCEPTED, $message, $variables, $type);
    // Check if this was the last unfinished job item in this job.
    $job = $this
      ->getJob();
    if ($job && !$job
      ->isContinuous() && tmgmt_job_check_finished($this
      ->getJobId())) {
      // Mark the job as finished in case it is a normal job.
      $job
        ->finished();
    }
    return $return;
  }
  /**
   * {@inheritdoc}
   */
  public function active($message = NULL, $variables = array(), $type = 'status') {
    if (!isset($message)) {
      $source_url = $this
        ->getSourceUrl();
      $message = $source_url ? 'The translation for <a href=":source_url">@source</a> is now being processed.' : 'The translation for @source is now being processed.';
      $variables = $source_url ? array(
        ':source_url' => $source_url
          ->toString(),
        '@source' => $this
          ->getSourceLabel(),
      ) : array(
        '@source' => $this
          ->getSourceLabel(),
      );
    }
    return $this
      ->setState(static::STATE_ACTIVE, $message, $variables, $type);
  }
  /**
   * {@inheritdoc}
   */
  public function setState($state, $message = NULL, $variables = array(), $type = 'debug') {
    // Return TRUE if the state could be set. Return FALSE otherwise.
    if (array_key_exists($state, JobItem::getStates()) && $this
      ->get('state')->value != $state) {
      $this
        ->set('state', $state);
      // Changing the state resets the translator state.
      $this
        ->setTranslatorState(NULL);
      $this
        ->save();
      // If a message is attached to this state change add it now.
      if (!empty($message)) {
        $this
          ->addMessage($message, $variables, $type);
      }
    }
    return $this
      ->get('state')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function getState() {
    return $this
      ->get('state')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function isState($state) {
    return $this
      ->getState() == $state;
  }
  /**
   * {@inheritdoc}
   */
  public function isAccepted() {
    return $this
      ->isState(static::STATE_ACCEPTED);
  }
  /**
   *
   * @return boolean
   */
  public function isAbortable() {
    if ($this
      ->isActive() || $this
      ->isNeedsReview()) {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }
  /**
   * {@inheritdoc}
   */
  public function isActive() {
    return $this
      ->isState(static::STATE_ACTIVE);
  }
  /**
   * {@inheritdoc}
   */
  public function isNeedsReview() {
    return $this
      ->isState(static::STATE_REVIEW);
  }
  /**
   * {@inheritdoc}
   */
  public function isAborted() {
    return $this
      ->isState(static::STATE_ABORTED);
  }
  /**
   * {@inheritdoc}
   */
  public function isInactive() {
    return $this
      ->isState(static::STATE_INACTIVE);
  }
  /**
   * {@inheritdoc}
   */
  public function getTranslatorState() {
    return $this
      ->get('translator_state')->value;
  }
  /**
   * {@inheritdoc}
   */
  public function setTranslatorState($translator_state = NULL) {
    $this
      ->get('translator_state')->value = $translator_state;
    return $this;
  }
  /**
   * Recursively writes translated data to the data array of a job item.
   *
   * While doing this the #status of each data item is set to
   * TMGMT_DATA_ITEM_STATE_TRANSLATED.
   *
   * @param array $translation
   *   Nested array of translated data. Can either be a single text entry, the
   *   whole data structure or parts of it.
   * @param array|string $key
   *   (Optional) Either a flattened key (a 'key1][key2][key3' string) or a
   *   nested one, e.g. array('key1', 'key2', 'key2'). Defaults to an empty
   *   array which means that it will replace the whole translated data array.
   * @param int|null $status
   *   (Optional) The data item status that will be set. Defaults to NULL,
   *   which means that it will be set to translated unless it was previously
   *   set to preliminary, then it will keep that state.
   *   Explicitly pass TMGMT_DATA_ITEM_STATE_TRANSLATED,
   *   TMGMT_DATA_ITEM_STATE_PRELIMINARY or TMGMT_DATA_ITEM_STATE_REVIEWED to
   *   set it to that value. Other statuses are not supported.
   *
   * @throws \Drupal\tmgmt\TMGMTException
   *   If is given an unsupported status.
   */
  protected function addTranslatedDataRecursive(array $translation, $key = array(), $status = NULL) {
    if ($status != NULL && !in_array($status, [
      TMGMT_DATA_ITEM_STATE_PRELIMINARY,
      TMGMT_DATA_ITEM_STATE_TRANSLATED,
      TMGMT_DATA_ITEM_STATE_REVIEWED,
    ])) {
      new TMGMTException('Unsupported status given.');
    }
    if (isset($translation['#text'])) {
      $data_service = \Drupal::service('tmgmt.data');
      $data = $this
        ->getData($data_service
        ->ensureArrayKey($key));
      if (empty($data['#status']) || $data['#status'] != TMGMT_DATA_ITEM_STATE_ACCEPTED) {
        // In case the origin is not set consider it to be remote.
        if (!isset($translation['#origin'])) {
          $translation['#origin'] = 'remote';
        }
        // If we already have a translation text and it hasn't changed, don't
        // update anything unless the origin is remote.
        if (!empty($data['#translation']['#text']) && $data['#translation']['#text'] == $translation['#text'] && $translation['#origin'] != 'remote') {
          return;
        }
        // In case the timestamp is not set consider it to be now.
        if (!isset($translation['#timestamp'])) {
          $translation['#timestamp'] = \Drupal::time()
            ->getRequestTime();
        }
        // If we have a translation text and is different from new one create
        // revision.
        if (!empty($data['#translation']['#text']) && $data['#translation']['#text'] != $translation['#text']) {
          // Copy into $translation existing revisions.
          if (!empty($data['#translation']['#text_revisions'])) {
            $translation['#text_revisions'] = $data['#translation']['#text_revisions'];
          }
          // If current translation was created locally and the incoming one is
          // remote, do not override the local, just create a new revision.
          if (isset($data['#translation']['#origin']) && $data['#translation']['#origin'] == 'local' && $translation['#origin'] == 'remote') {
            $translation['#text_revisions'][] = array(
              '#text' => $translation['#text'],
              '#origin' => $translation['#origin'],
              '#timestamp' => $translation['#timestamp'],
            );
            $this
              ->addMessage('Translation for customized @key received. Revert your changes if you wish to use it.', array(
              '@key' => $data_service
                ->ensureStringKey($key),
            ));
            // Unset text and origin so that the current translation does not
            // get overridden.
            unset($translation['#text'], $translation['#origin'], $translation['#timestamp']);
          }
          elseif ($translation['#origin'] == 'remote' && !empty($data['#status']) && $data['#status'] == TMGMT_DATA_ITEM_STATE_REVIEWED) {
            $translation['#text_revisions'][] = array(
              '#text' => $translation['#text'],
              '#origin' => $translation['#origin'],
              '#timestamp' => $translation['#timestamp'],
            );
            $this
              ->addMessage('Translation for already reviewed @key received and stored as a new revision. Revert to it if you wish to use it.', array(
              '@key' => $data_service
                ->ensureStringKey($key),
            ));
            // Unset text and origin so that the current translation does not
            // get overridden.
            unset($translation['#text'], $translation['#origin'], $translation['#timestamp']);
          }
          else {
            $translation['#text_revisions'][] = array(
              '#text' => $data['#translation']['#text'],
              '#origin' => isset($data['#translation']['#origin']) ? $data['#translation']['#origin'] : 'remote',
              '#timestamp' => isset($data['#translation']['#timestamp']) ? $data['#translation']['#timestamp'] : $this
                ->getChangedTime(),
            );
            // Add a message if the translation update is from remote.
            if ($translation['#origin'] == 'remote') {
              $diff = mb_strlen($translation['#text']) - mb_strlen($data['#translation']['#text']);
              $this
                ->addMessage('Updated translation for key @key, size difference: @diff characters.', array(
                '@key' => $data_service
                  ->ensureStringKey($key),
                '@diff' => $diff,
              ));
            }
          }
        }
        if ($status == NULL) {
          if (isset($data['#status']) && $data['#status'] == TMGMT_DATA_ITEM_STATE_PRELIMINARY) {
            $status = TMGMT_DATA_ITEM_STATE_PRELIMINARY;
          }
          else {
            $status = TMGMT_DATA_ITEM_STATE_TRANSLATED;
          }
        }
        $values = array(
          '#translation' => $translation,
          '#status' => $status,
        );
        $this
          ->updateData($key, $values);
      }
      return;
    }
    foreach (Element::children($translation) as $item) {
      $this
        ->addTranslatedDataRecursive($translation[$item], array_merge($key, array(
        $item,
      )), $status);
    }
  }
  /**
   * {@inheritdoc}
   */
  public function dataItemRevert(array $key) {
    $data = $this
      ->getData($key);
    if (!empty($data['#translation']['#text_revisions'])) {
      $prev_revision = end($data['#translation']['#text_revisions']);
      $data['#translation']['#text_revisions'][] = array(
        '#text' => $data['#translation']['#text'],
        '#timestamp' => $data['#translation']['#timestamp'],
        '#origin' => $data['#translation']['#origin'],
      );
      $data['#translation']['#text'] = $prev_revision['#text'];
      $data['#translation']['#origin'] = $prev_revision['#origin'];
      $data['#translation']['#timestamp'] = $prev_revision['#timestamp'];
      $this
        ->updateData($key, $data);
      $this
        ->addMessage('Translation for @key reverted to the latest version.', array(
        '@key' => $key[0],
      ));
      return TRUE;
    }
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function updateData($key, $values = array(), $replace = FALSE) {
    $this
      ->decodeData();
    if ($replace) {
      NestedArray::setValue($this->unserializedData, \Drupal::service('tmgmt.data')
        ->ensureArrayKey($key), $values);
    }
    foreach ($values as $index => $value) {
      // In order to preserve existing values, we can not aplly the values array
      // at once. We need to apply each containing value on its own.
      // If $value is an array we need to advance the hierarchy level.
      if (is_array($value)) {
        $this
          ->updateData(array_merge(\Drupal::service('tmgmt.data')
          ->ensureArrayKey($key), array(
          $index,
        )), $value);
      }
      else {
        NestedArray::setValue($this->unserializedData, array_merge(\Drupal::service('tmgmt.data')
          ->ensureArrayKey($key), array(
          $index,
        )), $value);
      }
    }
  }
  /**
   * {@inheritdoc}
   */
  public function resetData() {
    $this->data->value = NULL;
    $this->unserializedData = NULL;
    $this
      ->getData();
  }
  /**
   * {@inheritdoc}
   */
  public function addTranslatedData(array $translation, $key = array(), $status = NULL) {
    if ($this
      ->isInactive()) {
      // The job item can not be inactive and receive translations.
      $this
        ->setState(JobItemInterface::STATE_ACTIVE);
    }
    $this
      ->addTranslatedDataRecursive($translation, $key, $status);
    // Check if the job item has all the translated data that it needs now.
    // Only attempt to change the status to needs review if it is currently
    // active.
    if ($this
      ->isActive()) {
      $data = \Drupal::service('tmgmt.data')
        ->filterTranslatable($this
        ->getData());
      $finished = TRUE;
      foreach ($data as $item) {
        if (empty($item['#status']) || $item['#status'] == TMGMT_DATA_ITEM_STATE_PENDING || $item['#status'] == TMGMT_DATA_ITEM_STATE_PRELIMINARY) {
          $finished = FALSE;
          break;
        }
      }
      if ($finished && $this
        ->getJob()
        ->hasTranslator()) {
        // There are no unfinished elements left.
        if ($this
          ->getJob()
          ->getTranslator()
          ->isAutoAccept()) {
          // If the job item is going to be auto-accepted, set to review without
          // a message.
          $this
            ->needsReview(FALSE);
        }
        else {
          // Otherwise, create a message that contains source label, target
          // language and links to the review form.
          $job_url = $this
            ->getJob()
            ->toUrl()
            ->toString();
          $variables = array(
            '@source' => $this
              ->getSourceLabel(),
            '@language' => $this
              ->getJob()
              ->getTargetLanguage()
              ->getName(),
            ':review_url' => $this
              ->toUrl('canonical', array(
              'query' => array(
                'destination' => $job_url,
              ),
            ))
              ->toString(),
          );
          !$this
            ->getSourceUrl() ? $variables[':source_url'] = (string) $job_url : ($variables[':source_url'] = $this
            ->getSourceUrl()
            ->toString());
          $this
            ->needsReview('The translation of <a href=":source_url">@source</a> to @language is finished and can now be <a href=":review_url">reviewed</a>.', $variables);
        }
      }
    }
    $this
      ->save();
  }
  /**
   * {@inheritdoc}
   */
  public function acceptTranslation() {
    if (!$this
      ->isNeedsReview() || !($plugin = $this
      ->getSourcePlugin())) {
      return FALSE;
    }
    if (!$plugin
      ->saveTranslation($this, $this
      ->getJob()
      ->getTargetLangcode())) {
      return FALSE;
    }
    // If the plugin could save the translation, we will set it
    // to the 'accepted' state.
    $this
      ->accepted();
    return TRUE;
  }
  /**
   * {@inheritdoc}
   */
  public function abortTranslation() {
    if (!$this
      ->isActive() || !$this
      ->getTranslatorPlugin()) {
      throw new TMGMTException('Cannot abort job item.');
    }
    $this
      ->setState(JobItemInterface::STATE_ABORTED);
    // Check if this was the last unfinished job item in this job.
    $job = $this
      ->getJob();
    if ($job && !$job
      ->isContinuous() && tmgmt_job_check_finished($this
      ->getJobId())) {
      // Mark the job as finished in case it is a normal job.
      $job
        ->finished();
    }
  }
  /**
   * {@inheritdoc}
   */
  public function getMessages($conditions = array()) {
    $query = \Drupal::entityQuery('tmgmt_message')
      ->condition('tjiid', $this
      ->id());
    foreach ($conditions as $key => $condition) {
      if (is_array($condition)) {
        $operator = isset($condition['operator']) ? $condition['operator'] : '=';
        $query
          ->condition($key, $condition['value'], $operator);
      }
      else {
        $query
          ->condition($key, $condition);
      }
    }
    $results = $query
      ->execute();
    if (!empty($results)) {
      return Message::loadMultiple($results);
    }
    return array();
  }
  /**
   * {@inheritdoc}
   */
  public function getSiblings() {
    $ids = \Drupal::entityQuery('tmgmt_job_item')
      ->condition('tjiid', $this
      ->id(), '<>')
      ->condition('tjid', $this
      ->getJobId())
      ->execute();
    if ($ids) {
      return static::loadMultiple($ids);
    }
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function getMessagesSince($time = NULL) {
    $time = isset($time) ? $time : \Drupal::time()
      ->getRequestTime();
    $conditions = array(
      'created' => array(
        'value' => $time,
        'operator' => '>=',
      ),
    );
    return $this
      ->getMessages($conditions);
  }
  /**
   * {@inheritdoc}
   */
  public function addRemoteMapping($data_item_key = NULL, $remote_identifier_1 = NULL, $mapping_data = array()) {
    if (empty($remote_identifier_1) && !isset($mapping_data['remote_identifier_2']) && !isset($remote_mapping['remote_identifier_3'])) {
      throw new TMGMTException('Cannot create remote mapping without remote identifier.');
    }
    $data = array(
      'tjid' => $this
        ->getJobId(),
      'tjiid' => $this
        ->id(),
      'data_item_key' => $data_item_key,
      'remote_identifier_1' => $remote_identifier_1,
    );
    if (!empty($mapping_data)) {
      $data += $mapping_data;
    }
    $remote_mapping = RemoteMapping::create($data);
    return $remote_mapping
      ->save();
  }
  /**
   * {@inheritdoc}
   */
  public function getRemoteMappings() {
    $trids = \Drupal::entityQuery('tmgmt_remote')
      ->condition('tjiid', $this
      ->id())
      ->execute();
    if (!empty($trids)) {
      return RemoteMapping::loadMultiple($trids);
    }
    return array();
  }
  /**
   * {@inheritdoc}
   */
  public function getSourceLangCode() {
    return $this
      ->getSourcePlugin()
      ->getSourceLangCode($this);
  }
  /**
   * {@inheritdoc}
   */
  public function getExistingLangCodes() {
    return $this
      ->getSourcePlugin()
      ->getExistingLangCodes($this);
  }
  /**
   * {@inheritdoc}
   */
  public function recalculateStatistics() {
    // Set translatable data from the current entity to calculate words.
    $this
      ->decodeData();
    if (empty($this->unserializedData)) {
      $this->unserializedData = $this
        ->getSourceData();
    }
    // Consider everything accepted when the job item is accepted.
    if ($this
      ->isAccepted()) {
      $this->count_pending = 0;
      $this->count_translated = 0;
      $this->count_reviewed = 0;
      $this->count_accepted = count(array_filter(\Drupal::service('tmgmt.data')
        ->flatten($this->unserializedData), array(
        \Drupal::service('tmgmt.data'),
        'filterData',
      )));
    }
    else {
      // Reset counter values.
      $this->count_pending = 0;
      $this->count_translated = 0;
      $this->count_reviewed = 0;
      $this->count_accepted = 0;
      $this->word_count = 0;
      $this->tags_count = 0;
      $this
        ->count($this->unserializedData);
    }
  }
  /**
   * Sums up the counters for accepted, translated and pending items.
   *
   * @param array $item
   *   The current data item.
   */
  protected function count(&$item) {
    if (!empty($item['#text'])) {
      if (\Drupal::service('tmgmt.data')
        ->filterData($item)) {
        // Count words of the data item.
        $this->word_count->value += \Drupal::service('tmgmt.data')
          ->wordCount($item['#text']);
        // Count HTML tags of the data item.
        $this->tags_count->value += \Drupal::service('tmgmt.data')
          ->tagsCount($item['#text']);
        // Set default states if no state is set.
        if (!isset($item['#status'])) {
          // Translation is present.
          if (!empty($item['#translation'])) {
            $item['#status'] = TMGMT_DATA_ITEM_STATE_TRANSLATED;
          }
          else {
            $item['#status'] = TMGMT_DATA_ITEM_STATE_PENDING;
          }
        }
        switch ($item['#status']) {
          case TMGMT_DATA_ITEM_STATE_REVIEWED:
            $this->count_reviewed->value++;
            break;
          case TMGMT_DATA_ITEM_STATE_TRANSLATED:
            $this->count_translated->value++;
            break;
          default:
            $this->count_pending->value++;
            break;
        }
      }
    }
    elseif (is_array($item)) {
      foreach (Element::children($item) as $key) {
        $this
          ->count($item[$key]);
      }
    }
  }
  /**
   * {@inheritdoc}
   */
  public function language() {
    return new Language(array(
      'id' => Language::LANGCODE_NOT_SPECIFIED,
    ));
  }
  /**
   * {@inheritdoc}
   */
  protected function invalidateTagsOnSave($update) {
    parent::invalidateTagsOnSave($update);
    if ($this
      ->getJob()) {
      $tags = $this
        ->getJob()
        ->getEntityType()
        ->getListCacheTags();
      if ($update) {
        $tags = Cache::mergeTags($tags, $this
          ->getJob()
          ->getCacheTagsToInvalidate());
      }
      Cache::invalidateTags($tags);
    }
  }
  /**
   * {@inheritdoc}
   */
  public function getStateIcon() {
    $state_definitions = static::getStateDefinitions();
    $state_definition = NULL;
    $translator_state = $this
      ->getTranslatorState();
    if ($translator_state && isset($state_definitions[$translator_state]['icon'])) {
      $state_definition = $state_definitions[$translator_state];
    }
    elseif (isset($state_definitions[$this
      ->getState()]['icon'])) {
      $state_definition = $state_definitions[$this
        ->getState()];
    }
    if ($state_definition) {
      return [
        '#theme' => 'image',
        '#uri' => $state_definition['icon'],
        '#title' => $state_definition['label'],
        '#alt' => $state_definition['label'],
        '#width' => 16,
        '#height' => 16,
        '#weight' => $state_definition['weight'],
      ];
    }
  }
  /**
   * {@inheritdoc}
   */
  public static function getStates() {
    return array(
      static::STATE_ACTIVE => t('In progress'),
      static::STATE_REVIEW => t('Needs review'),
      static::STATE_ACCEPTED => t('Accepted'),
      static::STATE_ABORTED => t('Aborted'),
      static::STATE_INACTIVE => t('Inactive'),
    );
  }
  /**
   * {@inheritdoc}
   */
  public static function getStateDefinitions() {
    if (!empty(static::$stateDefinitions)) {
      return static::$stateDefinitions;
    }
    static::$stateDefinitions = [
      static::STATE_ACTIVE => [
        'label' => t('In progress'),
        'type' => 'state',
        'icon' => drupal_get_path('module', 'tmgmt') . '/icons/hourglass.svg',
        'weight' => 0,
        'show_job_filter' => TRUE,
      ],
      static::STATE_REVIEW => [
        'label' => t('Needs review'),
        'type' => 'state',
        'icon' => drupal_get_path('module', 'tmgmt') . '/icons/ready.svg',
        'weight' => 5,
        'show_job_filter' => TRUE,
      ],
      static::STATE_ACCEPTED => [
        'label' => t('Accepted'),
        'type' => 'state',
        'weight' => 10,
      ],
      static::STATE_ABORTED => [
        'label' => t('Aborted'),
        'type' => 'state',
        'weight' => 15,
      ],
      static::STATE_INACTIVE => [
        'label' => t('Inactive'),
        'type' => 'state',
        'icon' => drupal_get_path('module', 'tmgmt') . '/icons/rejected.svg',
        'weight' => 20,
      ],
    ];
    \Drupal::moduleHandler()
      ->alter('tmgmt_job_item_state_definitions', static::$stateDefinitions);
    foreach (static::$stateDefinitions as $key => &$definition) {
      // Ensure that all state definitions have a type and label key set.
      assert(!empty($definition['type']) && !empty($definition['label']), "State definition {$key} is missing label or type.");
      // Set the default weight to 25, after the default states.
      $definition += [
        'weight' => 25,
      ];
    }
    uasort(static::$stateDefinitions, [
      SortArray::class,
      'sortByWeightElement',
    ]);
    return static::$stateDefinitions;
  }
  /**
   * Ensures that the data is decoded.
   */
  protected function decodeData() {
    if (empty($this->unserializedData) && $this
      ->get('data')->value) {
      $this->unserializedData = (array) Json::decode($this
        ->get('data')->value);
    }
    if (!is_array($this->unserializedData)) {
      $this->unserializedData = [];
    }
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| CacheableDependencyTrait:: | protected | property | Cache contexts. | |
| CacheableDependencyTrait:: | protected | property | Cache max-age. | |
| CacheableDependencyTrait:: | protected | property | Cache tags. | |
| CacheableDependencyTrait:: | protected | function | Sets cacheability; useful for value object constructors. | |
| ContentEntityBase:: | protected | property | Language code identifying the entity active language. | |
| ContentEntityBase:: | protected | property | Local cache for the default language code. | |
| ContentEntityBase:: | protected | property | The default langcode entity key. | |
| ContentEntityBase:: | protected | property | Whether the revision translation affected flag has been enforced. | |
| ContentEntityBase:: | protected | property | Holds untranslatable entity keys such as the ID, bundle, and revision ID. | |
| ContentEntityBase:: | protected | property | Local cache for field definitions. | |
| ContentEntityBase:: | protected | property | The array of fields, each being an instance of FieldItemListInterface. | |
| ContentEntityBase:: | protected static | property | Local cache for fields to skip from the checking for translation changes. | |
| ContentEntityBase:: | protected | property | Indicates whether this is the default revision. | |
| ContentEntityBase:: | protected | property | The language entity key. | |
| ContentEntityBase:: | protected | property | Local cache for the available language objects. | |
| ContentEntityBase:: | protected | property | The loaded revision ID before the new revision was set. | |
| ContentEntityBase:: | protected | property | Boolean indicating whether a new revision should be created on save. | |
| ContentEntityBase:: | protected | property | The revision translation affected entity key. | |
| ContentEntityBase:: | protected | property | Holds translatable entity keys such as the label. | |
| ContentEntityBase:: | protected | property | A flag indicating whether a translation object is being initialized. | |
| ContentEntityBase:: | protected | property | An array of entity translation metadata. | |
| ContentEntityBase:: | protected | property | Whether entity validation was performed. | |
| ContentEntityBase:: | protected | property | Whether entity validation is required before saving the entity. | |
| ContentEntityBase:: | protected | property | The plain data values of the contained fields. | |
| ContentEntityBase:: | public | function | Checks data value access. Overrides EntityBase:: | 1 | 
| ContentEntityBase:: | public | function | Adds a new translation to the translatable object. Overrides TranslatableInterface:: | |
| ContentEntityBase:: | public | function | Gets the bundle of the entity. Overrides EntityBase:: | |
| ContentEntityBase:: | public static | function | Provides field definitions for a specific bundle. Overrides FieldableEntityInterface:: | 4 | 
| ContentEntityBase:: | protected | function | Clear entity translation object cache to remove stale references. | |
| ContentEntityBase:: | public | function | Creates a duplicate of the entity. Overrides EntityBase:: | 1 | 
| ContentEntityBase:: | public | function | Gets a field item list. Overrides FieldableEntityInterface:: | |
| ContentEntityBase:: | protected | function | Gets the value of the given entity key, if defined. | 1 | 
| ContentEntityBase:: | public | function | Gets the definition of a contained field. Overrides FieldableEntityInterface:: | |
| ContentEntityBase:: | public | function | Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface:: | |
| ContentEntityBase:: | public | function | Gets an array of all field item lists. Overrides FieldableEntityInterface:: | |
| ContentEntityBase:: | protected | function | Returns an array of field names to skip in ::hasTranslationChanges. | 1 | 
| ContentEntityBase:: | public | function | ||
| ContentEntityBase:: | protected | function | ||
| ContentEntityBase:: | public | function | Gets the loaded Revision ID of the entity. Overrides RevisionableInterface:: | |
| ContentEntityBase:: | public | function | Gets the revision identifier of the entity. Overrides RevisionableInterface:: | |
| ContentEntityBase:: | public | function | Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface:: | |
| ContentEntityBase:: | protected | function | Gets a translated field. | |
| ContentEntityBase:: | public | function | Gets a translation of the data. Overrides TranslatableInterface:: | |
| ContentEntityBase:: | public | function | Returns the languages the data is translated to. Overrides TranslatableInterface:: | |
| ContentEntityBase:: | public | function | Returns the translation status. Overrides TranslationStatusInterface:: | |
| ContentEntityBase:: | public | function | Returns the translatable object referring to the original language. Overrides TranslatableInterface:: | |
| ContentEntityBase:: | public | function | Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface:: | |
| ContentEntityBase:: | public | function | Checks there is a translation for the given language code. Overrides TranslatableInterface:: | |
| ContentEntityBase:: | public | function | Determines if the current translation of the entity has unsaved changes. Overrides TranslatableInterface:: | |
| ContentEntityBase:: | public | function | Gets the identifier. Overrides EntityBase:: | |
| ContentEntityBase:: | protected | function | Instantiates a translation object for an existing translation. | |
| ContentEntityBase:: | public | function | Checks if this entity is the default revision. Overrides RevisionableInterface:: | |
| ContentEntityBase:: | public | function | Checks whether the translation is the default one. Overrides TranslatableInterface:: | |
| ContentEntityBase:: | public | function | Checks if untranslatable fields should affect only the default translation. Overrides TranslatableRevisionableInterface:: | |
| ContentEntityBase:: | public | function | Checks if this entity is the latest revision. Overrides RevisionableInterface:: | |
| ContentEntityBase:: | public | function | Checks whether this is the latest revision affecting this translation. Overrides TranslatableRevisionableInterface:: | |
| ContentEntityBase:: | public | function | Determines whether a new revision should be created on save. Overrides RevisionableInterface:: | |
| ContentEntityBase:: | public | function | Checks whether the translation is new. Overrides TranslatableInterface:: | |
| ContentEntityBase:: | public | function | Checks whether the current translation is affected by the current revision. Overrides TranslatableRevisionableInterface:: | |
| ContentEntityBase:: | public | function | Checks if the revision translation affected flag value has been enforced. Overrides TranslatableRevisionableInterface:: | |
| ContentEntityBase:: | public | function | Returns the translation support status. Overrides TranslatableInterface:: | |
| ContentEntityBase:: | public | function | Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface:: | |
| ContentEntityBase:: | public | function | Reacts to changes to a field. Overrides FieldableEntityInterface:: | |
| ContentEntityBase:: | public | function | Acts on a created entity before hooks are invoked. Overrides EntityBase:: | |
| ContentEntityBase:: | public | function | Acts on a saved entity before the insert or update hook is invoked. Overrides EntityBase:: | 5 | 
| ContentEntityBase:: | public | function | Acts on a revision before it gets saved. Overrides RevisionableInterface:: | 2 | 
| ContentEntityBase:: | public | function | Gets a list of entities referenced by this entity. Overrides EntityBase:: | 1 | 
| ContentEntityBase:: | public | function | Removes the translation identified by the given language code. Overrides TranslatableInterface:: | |
| ContentEntityBase:: | public | function | Sets a field value. Overrides FieldableEntityInterface:: | |
| ContentEntityBase:: | protected | function | Populates the local cache for the default language code. | |
| ContentEntityBase:: | public | function | Enforces an entity to be saved as a new revision. Overrides RevisionableInterface:: | |
| ContentEntityBase:: | public | function | Marks the current revision translation as affected. Overrides TranslatableRevisionableInterface:: | |
| ContentEntityBase:: | public | function | Enforces the revision translation affected flag value. Overrides TranslatableRevisionableInterface:: | |
| ContentEntityBase:: | public | function | Sets whether entity validation is required before saving the entity. Overrides FieldableEntityInterface:: | |
| ContentEntityBase:: | public | function | Gets an array of all property values. Overrides EntityBase:: | |
| ContentEntityBase:: | protected | function | Updates language for already instantiated fields. | |
| ContentEntityBase:: | public | function | Updates the loaded Revision ID with the revision ID. Overrides RevisionableInterface:: | |
| ContentEntityBase:: | public | function | Updates the original values with the interim changes. | |
| ContentEntityBase:: | public | function | Gets the entity UUID (Universally Unique Identifier). Overrides EntityBase:: | |
| ContentEntityBase:: | public | function | Validates the currently set values. Overrides FieldableEntityInterface:: | |
| ContentEntityBase:: | public | function | Checks whether the entity object was a default revision when it was saved. Overrides RevisionableInterface:: | |
| ContentEntityBase:: | public | function | Magic method: Implements a deep clone. | |
| ContentEntityBase:: | public | function | Constructs an Entity object. Overrides EntityBase:: | |
| ContentEntityBase:: | public | function | Implements the magic method for getting object properties. | |
| ContentEntityBase:: | public | function | Implements the magic method for isset(). | |
| ContentEntityBase:: | public | function | Implements the magic method for setting object properties. | |
| ContentEntityBase:: | public | function | Overrides EntityBase:: | |
| ContentEntityBase:: | public | function | Implements the magic method for unset(). | |
| DependencySerializationTrait:: | protected | property | An array of entity type IDs keyed by the property name of their storages. | |
| DependencySerializationTrait:: | protected | property | An array of service IDs keyed by property name used for serialization. | |
| DependencySerializationTrait:: | public | function | Aliased as: traitSleep | 1 | 
| DependencySerializationTrait:: | public | function | 2 | |
| EntityBase:: | protected | property | Boolean indicating whether the entity should be forced to be new. | |
| EntityBase:: | protected | property | The entity type. | |
| EntityBase:: | protected | property | A typed data object wrapping this entity. | |
| EntityBase:: | public static | function | Constructs a new entity object, without permanently saving it. Overrides EntityInterface:: | |
| EntityBase:: | public | function | Deletes an entity permanently. Overrides EntityInterface:: | 2 | 
| EntityBase:: | public | function | Enforces an entity to be new. Overrides EntityInterface:: | |
| EntityBase:: | protected | function | Gets the entity manager. | |
| EntityBase:: | protected | function | Gets the entity type bundle info service. | |
| EntityBase:: | protected | function | Gets the entity type manager. | |
| EntityBase:: | public | function | The cache contexts associated with this object. Overrides CacheableDependencyTrait:: | |
| EntityBase:: | public | function | The maximum age for which this object may be cached. Overrides CacheableDependencyTrait:: | |
| EntityBase:: | public | function | The cache tags associated with this object. Overrides CacheableDependencyTrait:: | |
| EntityBase:: | public | function | Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface:: | 2 | 
| EntityBase:: | public | function | Gets the key that is used to store configuration dependencies. Overrides EntityInterface:: | |
| EntityBase:: | public | function | Gets the configuration dependency name. Overrides EntityInterface:: | 1 | 
| EntityBase:: | public | function | Gets the configuration target identifier for the entity. Overrides EntityInterface:: | 1 | 
| EntityBase:: | public | function | Gets the entity type definition. Overrides EntityInterface:: | |
| EntityBase:: | public | function | Gets the ID of the type of the entity. Overrides EntityInterface:: | |
| EntityBase:: | protected | function | The list cache tags to invalidate for this entity. | |
| EntityBase:: | public | function | Gets the original ID. Overrides EntityInterface:: | 1 | 
| EntityBase:: | public | function | Gets a typed data object for this entity object. Overrides EntityInterface:: | |
| EntityBase:: | public | function | Indicates if a link template exists for a given key. Overrides EntityInterface:: | |
| EntityBase:: | protected static | function | Invalidates an entity's cache tags upon delete. | 1 | 
| EntityBase:: | public | function | Determines whether the entity is new. Overrides EntityInterface:: | 2 | 
| EntityBase:: | protected | function | Gets the language manager. | |
| EntityBase:: | public | function | Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface:: | 1 | 
| EntityBase:: | protected | function | Gets an array link templates. | 1 | 
| EntityBase:: | public static | function | Loads an entity. Overrides EntityInterface:: | |
| EntityBase:: | public static | function | Loads one or more entities. Overrides EntityInterface:: | |
| EntityBase:: | public static | function | Acts on loaded entities. Overrides EntityInterface:: | 2 | 
| EntityBase:: | public static | function | Changes the values of an entity before it is created. Overrides EntityInterface:: | 5 | 
| EntityBase:: | public | function | Saves an entity permanently. Overrides EntityInterface:: | 3 | 
| EntityBase:: | public | function | Sets the original ID. Overrides EntityInterface:: | 1 | 
| EntityBase:: | public | function | Generates the HTML for a link to this entity. Overrides EntityInterface:: | |
| EntityBase:: | public | function | Gets the URL object for the entity. Overrides EntityInterface:: | 2 | 
| EntityBase:: | public | function | Gets a list of URI relationships supported by this entity. Overrides EntityInterface:: | |
| EntityBase:: | public | function | Gets the public URL for this entity. Overrides EntityInterface:: | 2 | 
| EntityBase:: | public | function | Gets the URL object for the entity. Overrides EntityInterface:: | 1 | 
| EntityBase:: | protected | function | Gets an array of placeholders for this entity. | 2 | 
| EntityBase:: | protected | function | Gets the UUID generator. | |
| EntityChangesDetectionTrait:: | protected | function | Returns an array of field names to skip when checking for changes. Aliased as: traitGetFieldsToSkipFromTranslationChangesCheck | |
| JobItem:: | protected static | property | Statically cached state definitions. | |
| JobItem:: | protected | property | Holds the unserialized source data. | |
| JobItem:: | public | function | Attempts to abort the translation job item. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Sets the state of the job item to 'accepted'. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Propagates the returned job item translations to the sources. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Sets the state of the job item to 'active'. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Add a log message for this job item. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Adds remote mapping entity to this job item. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Adds translated data to a job item. Overrides JobItemInterface:: | |
| JobItem:: | protected | function | Recursively writes translated data to the data array of a job item. | |
| JobItem:: | public static | function | Provides base field definitions for an entity type. Overrides ContentEntityBase:: | |
| JobItem:: | public | function | ||
| JobItem:: | protected | function | Sums up the counters for accepted, translated and pending items. | |
| JobItem:: | public | function | Reverts data item translation to the latest existing revision. Overrides JobItemInterface:: | |
| JobItem:: | protected | function | Ensures that the data is decoded. | |
| JobItem:: | public | function | ||
| JobItem:: | public | function | Count of all accepted data items. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Count of all pending data items. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Count of all accepted data items. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Count of all translated data items. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Array of the data to be translated. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Gets existing translation language codes of the job item source. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Returns the item ID. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Returns the item type. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Loads the job entity that this job item is attached to. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Returns the Job ID. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Returns all job item messages attached to this job item. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Returns all job item messages attached to this job item with timestamp
newer than $time. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Returns the plugin. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Gets remote mappings for current job item. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Retrieves all siblings of this job item. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Loads the structured source data array from the source. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Retrieves the label of the source object via the source controller. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Gets language code of the job item source. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Returns an instance of the configured source plugin. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Returns the user readable type of job item. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Retrieves the path to the source object via the source controller. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Returns the state of the job item. Can be one of the job item state
constants. Overrides JobItemInterface:: | |
| JobItem:: | public static | function | ||
| JobItem:: | public | function | Returns a render array to display a job item state icon. Overrides JobItemInterface:: | |
| JobItem:: | public static | function | Returns a labeled list of all available states. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Tags count of all data items. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Returns the translator for this job item. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Returns the translator plugin of the translator of this job item. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Returns the current translator state. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Word count of all data items. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Checks if the translator exists. Overrides JobItemInterface:: | |
| JobItem:: | protected | function | Invalidates an entity's cache tags upon save. Overrides EntityBase:: | |
| JobItem:: | public | function | ||
| JobItem:: | public | function | Checks whether the state of this transaction is 'aborted'. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Checks whether the state of this transaction is 'accepted'. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Checks whether the state of this transaction is 'active'. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Checks whether the state of this transaction is 'inactive'. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Checks whether the state of this transaction is 'needs review'. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Checks whether the passed value matches the current state. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Gets the label of the entity. Overrides ContentEntityBase:: | |
| JobItem:: | public | function | Gets the language of the entity. Overrides ContentEntityBase:: | |
| JobItem:: | public | function | Sets the state of the job item to 'needs review'. Overrides JobItemInterface:: | |
| JobItem:: | public static | function | Acts on deleted entities before the delete hook is invoked. Overrides EntityBase:: | |
| JobItem:: | public static | function | Acts on entities before they are deleted and before hooks are invoked. Overrides EntityBase:: | |
| JobItem:: | public | function | Acts on an entity before the presave hook is invoked. Overrides ContentEntityBase:: | |
| JobItem:: | public | function | Recalculate statistical word-data: pending, translated, reviewed, accepted. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Resets job item data arrays. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Updates the state of the job item. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Sets the translator state. Overrides JobItemInterface:: | |
| JobItem:: | public | function | Updates the values for a specific substructure in the data array. Overrides JobItemInterface:: | |
| JobItemInterface:: | constant | The translation process of the job item is aborted. | ||
| JobItemInterface:: | constant | The translation job item has been reviewed and accepted. | ||
| JobItemInterface:: | constant | The translation job item is active and waiting to be translated. | ||
| JobItemInterface:: | constant | The translation job item is inactive. | ||
| JobItemInterface:: | constant | The translation job item needs to be reviewed. | ||
| RefinableCacheableDependencyTrait:: | public | function | 1 | |
| RefinableCacheableDependencyTrait:: | public | function | ||
| RefinableCacheableDependencyTrait:: | public | function | ||
| RefinableCacheableDependencyTrait:: | public | function | ||
| SynchronizableEntityTrait:: | protected | property | Whether this entity is being created, updated or deleted through a synchronization process. | |
| SynchronizableEntityTrait:: | public | function | ||
| SynchronizableEntityTrait:: | public | function | ||
| TranslationStatusInterface:: | constant | Status code identifying a newly created translation. | ||
| TranslationStatusInterface:: | constant | Status code identifying an existing translation. | ||
| TranslationStatusInterface:: | constant | Status code identifying a removed translation. | 
