You are here

class Feed in Feeds 8.3

Same name in this branch
  1. 8.3 src/Utility/Feed.php \Drupal\feeds\Utility\Feed
  2. 8.3 src/Entity/Feed.php \Drupal\feeds\Entity\Feed

Defines the feed entity class.

Plugin annotation


@ContentEntityType(
  id = "feeds_feed",
  label = @Translation("Feed"),
  bundle_label = @Translation("Feed type"),
  module = "feeds",
  handlers = {
    "storage" = "Drupal\feeds\FeedStorage",
    "view_builder" = "Drupal\feeds\FeedViewBuilder",
    "access" = "Drupal\feeds\FeedAccessControlHandler",
    "views_data" = "Drupal\feeds\FeedViewsData",
    "form" = {
      "default" = "Drupal\feeds\FeedForm",
      "update" = "Drupal\feeds\FeedForm",
      "delete" = "Drupal\feeds\Form\FeedDeleteForm",
      "import" = "Drupal\feeds\Form\FeedImportForm",
      "schedule_import" = "Drupal\feeds\Form\FeedScheduleImportForm",
      "clear" = "Drupal\feeds\Form\FeedClearForm",
      "unlock" = "Drupal\feeds\Form\FeedUnlockForm",
    },
    "list_builder" = "Drupal\feeds\FeedListBuilder",
    "route_provider" = {
      "html" = "Drupal\Core\Entity\Routing\AdminHtmlRouteProvider",
    },
    "feed_import" = "Drupal\feeds\FeedImportHandler",
    "feed_clear" = "Drupal\feeds\FeedClearHandler",
    "feed_expire" = "Drupal\feeds\FeedExpireHandler"
  },
  base_table = "feeds_feed",
  fieldable = TRUE,
  entity_keys = {
    "id" = "fid",
    "bundle" = "type",
    "label" = "title",
    "uuid" = "uuid"
  },
  permission_granularity = "bundle",
  bundle_entity_type = "feeds_feed_type",
  field_ui_base_route = "entity.feeds_feed_type.edit_form",
  links = {
    "canonical" = "/feed/{feeds_feed}",
    "add-page" = "/feed/add",
    "add-form" = "/feed/add/{feeds_feed_type}",
    "delete-form" = "/feed/{feeds_feed}/delete",
    "edit-form" = "/feed/{feeds_feed}/edit",
    "import-form" = "/feed/{feeds_feed}/import",
    "schedule-import-form" = "/feed/{feeds_feed}/schedule-import",
    "clear-form" = "/feed/{feeds_feed}/delete-items"
  }
)

Hierarchy

Expanded class hierarchy of Feed

7 files declare their use of Feed
CsvParserFeedFormTest.php in tests/src/Functional/Feeds/Parser/Form/CsvParserFeedFormTest.php
CsvParserTest.php in tests/src/FunctionalJavascript/Feeds/Parser/CsvParserTest.php
DeleteFeedTest.php in tests/src/Functional/Plugin/Action/DeleteFeedTest.php
FeedCreationTrait.php in tests/src/Traits/FeedCreationTrait.php
feeds.module in ./feeds.module
Feeds hook implementations.

... See full list

File

src/Entity/Feed.php, line 81

Namespace

Drupal\feeds\Entity
View source
class Feed extends ContentEntityBase implements FeedInterface {
  use EntityChangedTrait;

  /**
   * An array of import stage states keyed by state.
   *
   * @var array
   */
  protected $states;

  /**
   * Implements the magic __wakeup function to reset states.
   */
  public function __wakeup() {
    $this->states = [];
  }

  /**
   * Gets the event dispatcher.
   *
   * @return \Symfony\Component\EventDispatcher\EventDispatcherInterface
   *   The event dispatcher service.
   */
  protected function eventDispatcher() {
    return \Drupal::service('event_dispatcher');
  }

  /**
   * {@inheritdoc}
   */
  public function id() {
    return $this
      ->get('fid')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function label() {
    return $this
      ->get('title')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function getSource() {
    return $this
      ->get('source')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setSource($source) {
    return $this
      ->set('source', $source);
  }

  /**
   * {@inheritdoc}
   */
  public function getCreatedTime() {
    return (int) $this
      ->get('created')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setCreatedTime($timestamp) {
    $this
      ->set('created', (int) $timestamp);
  }

  /**
   * {@inheritdoc}
   */
  public function getChangedTime() {
    return (int) $this
      ->get('changed')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function getImportedTime() {
    return (int) $this
      ->get('imported')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function getNextImportTime() {
    return (int) $this
      ->get('next')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function getQueuedTime() {
    return (int) $this
      ->get('queued')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setQueuedTime($queued) {
    $this
      ->set('queued', (int) $queued);
  }

  /**
   * {@inheritdoc}
   */
  public function getType() {
    $type = $this
      ->get('type')->entity;
    if (empty($type)) {
      if ($this
        ->id()) {
        throw new EntityStorageException(strtr('The feed type "@type" for feed @id no longer exists.', [
          '@type' => $this
            ->bundle(),
          '@id' => $this
            ->id(),
        ]));
      }
      else {
        throw new EntityStorageException(strtr('The feed type "@type" no longer exists.', [
          '@type' => $this
            ->bundle(),
        ]));
      }
    }
    return $type;
  }

  /**
   * {@inheritdoc}
   */
  public function getOwner() {
    return $this
      ->get('uid')->entity;
  }

  /**
   * {@inheritdoc}
   */
  public function getOwnerId() {
    return $this
      ->get('uid')->target_id;
  }

  /**
   * {@inheritdoc}
   */
  public function setOwnerId($uid) {
    $this
      ->set('uid', $uid);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setOwner(UserInterface $account) {
    $this
      ->set('uid', $account
      ->id());
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function isActive() {
    return (bool) $this
      ->get('status')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setActive($active) {
    $this
      ->set('status', $active ? static::ACTIVE : static::INACTIVE);
  }

  /**
   * {@inheritdoc}
   */
  public function import() {
    $this
      ->entityTypeManager()
      ->getHandler('feeds_feed', 'feed_import')
      ->import($this);
  }

  /**
   * {@inheritdoc}
   */
  public function startBatchImport() {
    $this
      ->entityTypeManager()
      ->getHandler('feeds_feed', 'feed_import')
      ->startBatchImport($this);
  }

  /**
   * {@inheritdoc}
   */
  public function startCronImport() {
    $this
      ->entityTypeManager()
      ->getHandler('feeds_feed', 'feed_import')
      ->startCronImport($this);
  }

  /**
   * {@inheritdoc}
   */
  public function pushImport($raw) {
    return $this
      ->entityTypeManager()
      ->getHandler('feeds_feed', 'feed_import')
      ->pushImport($this, $raw);
  }

  /**
   * {@inheritdoc}
   */
  public function startBatchClear() {
    $this
      ->entityTypeManager()
      ->getHandler('feeds_feed', 'feed_clear')
      ->startBatchClear($this);
  }

  /**
   * {@inheritdoc}
   */
  public function startBatchExpire() {
    return $this
      ->entityTypeManager()
      ->getHandler('feeds_feed', 'feed_expire')
      ->startBatchExpire($this);
  }

  /**
   * {@inheritdoc}
   */
  public function dispatchEntityEvent($event, EntityInterface $entity, ItemInterface $item) {
    return $this
      ->eventDispatcher()
      ->dispatch($event, new EntityEvent($this, $entity, $item));
  }

  /**
   * {@inheritdoc}
   */
  public function finishImport() {
    $time = time();
    $this
      ->getType()
      ->getProcessor()
      ->postProcess($this, $this
      ->getState(StateInterface::PROCESS));
    foreach ($this->states as $state) {
      if (is_object($state)) {
        $state
          ->displayMessages();
        $state
          ->logMessages($this);
      }
    }

    // Allow other modules to react upon finishing importing.
    $this
      ->eventDispatcher()
      ->dispatch(FeedsEvents::IMPORT_FINISHED, new ImportFinishedEvent($this));

    // Cleanup.
    $this
      ->clearStates();
    $this
      ->setQueuedTime(0);
    $this
      ->set('imported', $time);
    $interval = $this
      ->getType()
      ->getImportPeriod();
    if ($interval !== FeedTypeInterface::SCHEDULE_NEVER) {
      $this
        ->set('next', $interval + $time);
    }
    $this
      ->save();
    $this
      ->unlock();
  }

  /**
   * Cleans up after an import.
   */
  public function finishClear() {
    $this
      ->getType()
      ->getProcessor()
      ->postClear($this, $this
      ->getState(StateInterface::CLEAR));
    foreach ($this->states as $state) {
      is_object($state) ? $state
        ->displayMessages() : NULL;
    }
    $this
      ->clearStates();
  }

  /**
   * {@inheritdoc}
   */
  public function getState($stage) {
    if (!isset($this->states[$stage])) {
      $state = \Drupal::keyValue('feeds_feed.' . $this
        ->id())
        ->get($stage);
      if (empty($state)) {

        // @todo move this logic to a factory or alike.
        switch ($stage) {
          case StateInterface::CLEAN:
            $state = new CleanState($this
              ->id());
            break;
          default:
            $state = new State();
            break;
        }
      }
      $this->states[$stage] = $state;
    }
    return $this->states[$stage];
  }

  /**
   * {@inheritdoc}
   */
  public function setState($stage, StateInterface $state = NULL) {
    $this->states[$stage] = $state;
  }

  /**
   * {@inheritdoc}
   */
  public function clearStates() {
    $this->states = [];
    \Drupal::keyValue('feeds_feed.' . $this
      ->id())
      ->deleteAll();

    // Clean up references in feeds_clean_list table for this feed.
    \Drupal::database()
      ->delete(CleanState::TABLE_NAME)
      ->condition('feed_id', $this
      ->id())
      ->execute();
  }

  /**
   * {@inheritdoc}
   */
  public function saveStates() {
    \Drupal::keyValue('feeds_feed.' . $this
      ->id())
      ->setMultiple($this->states);
  }

  /**
   * {@inheritdoc}
   */
  public function progressFetching() {
    return $this
      ->getState(StateInterface::FETCH)->progress;
  }

  /**
   * {@inheritdoc}
   */
  public function progressParsing() {
    return $this
      ->getState(StateInterface::PARSE)->progress;
  }

  /**
   * {@inheritdoc}
   */
  public function progressImporting() {
    $fetcher = $this
      ->getState(StateInterface::FETCH);
    $parser = $this
      ->getState(StateInterface::PARSE);
    if ($fetcher->progress === StateInterface::BATCH_COMPLETE && $parser->progress === StateInterface::BATCH_COMPLETE) {
      return StateInterface::BATCH_COMPLETE;
    }

    // Fetching envelops parsing.
    // @todo: this assumes all fetchers neatly use total. May not be the case.
    $fetcher_fraction = $fetcher->total ? 1.0 / $fetcher->total : 1.0;
    $parser_progress = $parser->progress * $fetcher_fraction;
    $result = $fetcher->progress - $fetcher_fraction + $parser_progress;
    if ($result >= StateInterface::BATCH_COMPLETE) {
      return 0.99;
    }
    return $result;
  }

  /**
   * {@inheritdoc}
   */
  public function progressCleaning() {
    return $this
      ->getState(StateInterface::CLEAN)->progress;
  }

  /**
   * {@inheritdoc}
   */
  public function progressClearing() {
    return $this
      ->getState(StateInterface::CLEAR)->progress;
  }

  /**
   * {@inheritdoc}
   */
  public function progressExpiring() {
    return $this
      ->getState(StateInterface::EXPIRE)->progress;
  }

  /**
   * {@inheritdoc}
   */
  public function getItemCount() {
    return (int) $this
      ->get('item_count')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function lock() {
    if (!\Drupal::service('lock.persistent')
      ->acquire("feeds_feed_{$this->id()}", 3600 * 12)) {
      $args = [
        '@id' => $this
          ->bundle(),
        '@fid' => $this
          ->id(),
      ];
      throw new LockException(new FormattableMarkup('Cannot acquire lock for feed @id / @fid.', $args));
    }
    Cache::invalidateTags([
      'feeds_feed_locked',
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function unlock() {
    \Drupal::service('lock.persistent')
      ->release("feeds_feed_{$this->id()}");
    Cache::invalidateTags([
      'feeds_feed_locked',
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function isLocked() {
    return !\Drupal::service('lock.persistent')
      ->lockMayBeAvailable("feeds_feed_{$this->id()}");
  }

  /**
   * {@inheritdoc}
   */
  public function getConfigurationFor(FeedsPluginInterface $client) {
    $type = $client
      ->pluginType();

    // @todo Figure out why for the UploadFetcher there is no config available.
    $data = $this
      ->get('config')->{$type};
    $data = !empty($data) ? $data : [];
    return $data + $client
      ->defaultFeedConfiguration();
  }

  /**
   * {@inheritdoc}
   */
  public function setConfigurationFor(FeedsPluginInterface $client, array $configuration) {
    $type = $client
      ->pluginType();
    $this
      ->get('config')->{$type} = array_intersect_key($configuration, $client
      ->defaultFeedConfiguration()) + $client
      ->defaultFeedConfiguration();
  }

  /**
   * {@inheritdoc}
   */
  public function preSave(EntityStorageInterface $storage_controller, $update = TRUE) {
    $feed_type = $this
      ->getType();
    foreach ($feed_type
      ->getPlugins() as $plugin) {
      $plugin
        ->onFeedSave($this, $update);
    }

    // If this is a new node, 'next' and 'imported' will be zero which will
    // queue it for the next run.
    if ($feed_type
      ->getImportPeriod() === FeedTypeInterface::SCHEDULE_NEVER) {
      $this
        ->set('next', FeedTypeInterface::SCHEDULE_NEVER);
    }

    // Update the item count.
    $this
      ->set('item_count', $feed_type
      ->getProcessor()
      ->getItemCount($this));
  }

  /**
   * {@inheritdoc}
   */
  public static function postDelete(EntityStorageInterface $storage_controller, array $feeds) {

    // Delete values from other tables also referencing these feeds.
    $ids = array_keys($feeds);

    // Group feeds by type.
    $grouped = [];
    foreach ($feeds as $fid => $feed) {
      $grouped[$feed
        ->bundle()][$fid] = $feed;
    }

    // Alert plugins that we are deleting.
    foreach ($grouped as $group) {

      // Grab the first feed to get its type.
      $feed = reset($group);
      try {
        foreach ($feed
          ->getType()
          ->getPlugins() as $plugin) {
          $plugin
            ->onFeedDeleteMultiple($group);
        }
      } catch (EntityStorageException $e) {

        // Ignore the case where the feed type no longer exists, but do log an
        // error.
        $args = [
          '%title' => $feed
            ->label(),
          '@error' => $e
            ->getMessage(),
        ];
        \Drupal::logger('feeds')
          ->warning('Could not perform some post cleanups for feed %title because of the following error: @error', $args);
      }
    }

    // Clean up references in feeds_clean_list table for each feed.
    \Drupal::database()
      ->delete(CleanState::TABLE_NAME)
      ->condition('feed_id', $ids, 'IN')
      ->execute();
    \Drupal::service('event_dispatcher')
      ->dispatch(FeedsEvents::FEEDS_DELETE, new DeleteFeedsEvent($feeds));
  }

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = [];
    $fields['fid'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Feed ID'))
      ->setDescription(t('The feed ID.'))
      ->setReadOnly(TRUE)
      ->setSetting('unsigned', TRUE);
    $fields['uuid'] = BaseFieldDefinition::create('uuid')
      ->setLabel(t('UUID'))
      ->setDescription(t('The feed UUID.'))
      ->setReadOnly(TRUE);
    $fields['type'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Feed type'))
      ->setDescription(t('The feed type.'))
      ->setSetting('target_type', 'feeds_feed_type')
      ->setReadOnly(TRUE);
    $fields['title'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Title'))
      ->setDescription(t('The title of this feed, always treated as non-markup plain text.'))
      ->setRequired(TRUE)
      ->setDefaultValue('')
      ->setSetting('max_length', 255)
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'string',
      'weight' => -5,
    ])
      ->setDisplayOptions('form', [
      'type' => 'string_textfield',
      'weight' => -5,
    ])
      ->setDisplayConfigurable('form', TRUE);
    $fields['uid'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Authored by'))
      ->setDescription(t('The user ID of the feed author.'))
      ->setRevisionable(TRUE)
      ->setSetting('target_type', 'user')
      ->setSetting('handler', 'default')
      ->setDefaultValueCallback('Drupal\\feeds\\Entity\\Feed::getCurrentUserId')
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'author',
      'weight' => 0,
    ])
      ->setDisplayOptions('form', [
      'type' => 'entity_reference_autocomplete',
      'weight' => 5,
      'settings' => [
        'match_operator' => 'CONTAINS',
        'size' => '60',
        'autocomplete_type' => 'tags',
        'placeholder' => '',
      ],
    ])
      ->setDisplayConfigurable('form', TRUE);
    $fields['status'] = BaseFieldDefinition::create('boolean')
      ->setLabel(t('Importing status'))
      ->setDescription(t('A boolean indicating whether the feed is active.'))
      ->setDefaultValue(TRUE);
    $fields['created'] = BaseFieldDefinition::create('created')
      ->setLabel(t('Authored on'))
      ->setDescription(t('The time that the feed was created.'))
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'timestamp',
      'weight' => 0,
    ])
      ->setDisplayOptions('form', [
      'type' => 'datetime_timestamp',
      'weight' => 10,
    ])
      ->setDisplayConfigurable('form', TRUE);
    $fields['changed'] = BaseFieldDefinition::create('changed')
      ->setLabel(t('Changed'))
      ->setDescription(t('The time that the feed was last edited.'));
    $fields['imported'] = BaseFieldDefinition::create('timestamp')
      ->setLabel(t('Last import'))
      ->setDescription(t('The time that the feed was imported.'))
      ->setDefaultValue(0)
      ->setDisplayOptions('view', [
      'label' => 'inline',
      'type' => 'timestamp_ago',
      'weight' => 1,
    ])
      ->setDisplayConfigurable('view', TRUE);
    $fields['next'] = BaseFieldDefinition::create('timestamp')
      ->setLabel(t('Next import'))
      ->setDescription(t('The time that the feed will import next.'))
      ->setDefaultValue(0)
      ->setDisplayOptions('view', [
      'label' => 'inline',
      'type' => 'timestamp',
      'weight' => 1,
    ])
      ->setDisplayConfigurable('view', TRUE);
    $fields['queued'] = BaseFieldDefinition::create('timestamp')
      ->setLabel(t('Queued'))
      ->setDescription(t('Time when this feed was queued for refresh, 0 if not queued.'))
      ->setDefaultValue(0);
    $fields['source'] = BaseFieldDefinition::create('uri')
      ->setLabel(t('Source'))
      ->setDescription(t('The source of the feed.'))
      ->setRequired(TRUE)
      ->setDisplayOptions('view', [
      'label' => 'inline',
      'type' => 'feeds_uri_link',
      'weight' => -3,
    ])
      ->setDisplayConfigurable('view', TRUE);
    $fields['config'] = BaseFieldDefinition::create('map')
      ->setLabel(t('Config'))
      ->setDescription(t('The config of the feed.'));
    $fields['item_count'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Items imported'))
      ->setDescription(t('The number of items imported.'))
      ->setDefaultValue(0)
      ->setDisplayOptions('view', [
      'label' => 'inline',
      'type' => 'number_integer',
      'weight' => 0,
    ]);
    return $fields;
  }

  /**
   * Default value callback for 'uid' base field definition.
   *
   * @see ::baseFieldDefinitions()
   *
   * @return array
   *   An array of default values.
   */
  public static function getCurrentUserId() {
    return [
      \Drupal::currentUser()
        ->id(),
    ];
  }

}

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::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::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::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
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::postLoad public static function Acts on loaded entities. Overrides EntityInterface::postLoad 2
EntityBase::preCreate public static function Changes the values of an entity before it is created. Overrides EntityInterface::preCreate 5
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::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
Feed::$states protected property An array of import stage states keyed by state.
Feed::baseFieldDefinitions public static function Provides base field definitions for an entity type. Overrides ContentEntityBase::baseFieldDefinitions
Feed::clearStates public function Clears all state objects for the feed. Overrides FeedInterface::clearStates
Feed::dispatchEntityEvent public function Dispatches an entity event. Overrides FeedInterface::dispatchEntityEvent
Feed::eventDispatcher protected function Gets the event dispatcher.
Feed::finishClear public function Cleans up after an import. Overrides FeedInterface::finishClear
Feed::finishImport public function Cleans up after an import. Overrides FeedInterface::finishImport
Feed::getChangedTime public function Gets the timestamp of the last entity change for the current translation. Overrides EntityChangedTrait::getChangedTime
Feed::getConfigurationFor public function Returns the configuration for a specific client plugin. Overrides FeedInterface::getConfigurationFor
Feed::getCreatedTime public function Returns the feed creation timestamp. Overrides FeedInterface::getCreatedTime
Feed::getCurrentUserId public static function Default value callback for 'uid' base field definition.
Feed::getImportedTime public function Returns the feed imported timestamp. Overrides FeedInterface::getImportedTime
Feed::getItemCount public function Counts items imported by this feed. Overrides FeedInterface::getItemCount
Feed::getNextImportTime public function Returns the next time the feed will be imported. Overrides FeedInterface::getNextImportTime
Feed::getOwner public function Returns the entity owner's user entity. Overrides EntityOwnerInterface::getOwner
Feed::getOwnerId public function Returns the entity owner's user ID. Overrides EntityOwnerInterface::getOwnerId
Feed::getQueuedTime public function Returns the time when this feed was queued for refresh, 0 if not queued. Overrides FeedInterface::getQueuedTime
Feed::getSource public function Returns the source of the feed. Overrides FeedInterface::getSource
Feed::getState public function Returns a state object for a given stage. Overrides FeedInterface::getState
Feed::getType public function Returns the feed type object that this feed is expected to be used with. Overrides FeedInterface::getType
Feed::id public function Gets the identifier. Overrides ContentEntityBase::id
Feed::import public function Imports the whole feed at once. Overrides FeedInterface::import
Feed::isActive public function Returns the feed active status. Overrides FeedInterface::isActive
Feed::isLocked public function Checks whether a feed is locked. Overrides FeedInterface::isLocked
Feed::label public function Gets the label of the entity. Overrides ContentEntityBase::label
Feed::lock public function Locks a feed. Overrides FeedInterface::lock
Feed::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityBase::postDelete
Feed::preSave public function Acts on an entity before the presave hook is invoked. Overrides ContentEntityBase::preSave
Feed::progressCleaning public function Reports progress on cleaning. Overrides FeedInterface::progressCleaning
Feed::progressClearing public function Reports progress on clearing. Overrides FeedInterface::progressClearing
Feed::progressExpiring public function Reports progress on expiry. Overrides FeedInterface::progressExpiring
Feed::progressFetching public function Reports the progress of the fetching stage. Overrides FeedInterface::progressFetching
Feed::progressImporting public function Reports the progress of the import process. Overrides FeedInterface::progressImporting
Feed::progressParsing public function Reports the progress of the parsing stage. Overrides FeedInterface::progressParsing
Feed::pushImport public function Imports a raw string. Overrides FeedInterface::pushImport
Feed::saveStates public function Saves all state objects on the key/value collection of the feed. Overrides FeedInterface::saveStates
Feed::setActive public function Sets the active status of a feed. Overrides FeedInterface::setActive
Feed::setConfigurationFor public function Sets the configuration for a specific client plugin. Overrides FeedInterface::setConfigurationFor
Feed::setCreatedTime public function Sets the feed creation timestamp. Overrides FeedInterface::setCreatedTime
Feed::setOwner public function Sets the entity owner's user entity. Overrides EntityOwnerInterface::setOwner
Feed::setOwnerId public function Sets the entity owner's user ID. Overrides EntityOwnerInterface::setOwnerId
Feed::setQueuedTime public function Sets the time when this feed was queued for refresh, 0 if not queued. Overrides FeedInterface::setQueuedTime
Feed::setSource public function Sets the feed source. Overrides FeedInterface::setSource
Feed::setState public function Sets a state object for a given stage. Overrides FeedInterface::setState
Feed::startBatchClear public function Start deleting all imported items of a feed via the batch API. Overrides FeedInterface::startBatchClear
Feed::startBatchExpire public function Removes all expired items from a feed via batch api. Overrides FeedInterface::startBatchExpire
Feed::startBatchImport public function Starts importing a feed via the batch API. Overrides FeedInterface::startBatchImport
Feed::startCronImport public function Starts importing a feed via cron. Overrides FeedInterface::startCronImport
Feed::unlock public function Unlocks a feed. Overrides FeedInterface::unlock
Feed::__wakeup public function Implements the magic __wakeup function to reset states. Overrides DependencySerializationTrait::__wakeup
FeedInterface::ACTIVE constant Represents an active feed.
FeedInterface::INACTIVE constant Represents an inactive feed.
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.