You are here

class PhotosImage in Album Photos 6.0.x

Same name in this branch
  1. 6.0.x src/Entity/PhotosImage.php \Drupal\photos\Entity\PhotosImage
  2. 6.0.x src/Plugin/migrate/source/PhotosImage.php \Drupal\photos\Plugin\migrate\source\PhotosImage
  3. 6.0.x src/Plugin/migrate/destination/PhotosImage.php \Drupal\photos\Plugin\migrate\destination\PhotosImage
Same name and namespace in other branches
  1. 8.5 src/Entity/PhotosImage.php \Drupal\photos\Entity\PhotosImage

Defines the photos image entity class.

@todo Remove default/fallback entity form operation when #2006348 is done.

Plugin annotation


@ContentEntityType(
  id = "photos_image",
  label = @Translation("Photo"),
  label_collection = @Translation("Photos"),
  label_singular = @Translation("photo"),
  label_plural = @Translation("photos"),
  label_count = @PluralTranslation(
    singular = "@count photo",
    plural = "@count photos"
  ),
  handlers = {
    "storage" = "Drupal\photos\PhotosImageStorage",
    "storage_schema" = "Drupal\photos\PhotosImageStorageSchema",
    "form" = {
      "default" = "Drupal\photos\Form\PhotosImageAddForm",
      "add" = "Drupal\photos\Form\PhotosImageAddForm",
      "edit" = "Drupal\photos\Form\PhotosImageEditForm",
      "delete" = "Drupal\photos\Form\PhotosImageDeleteForm",
      "delete-multiple-confirm" = "Drupal\Core\Entity\Form\DeleteMultipleForm",
    },
    "access" = "Drupal\photos\PhotosAccessControlHandler",
    "views_data" = "Drupal\photos\PhotosViewsData",
    "list_builder" = "Drupal\photos\PhotosImageListBuilder",
    "route_provider" = {
      "html" = "Drupal\photos\Entity\PhotosRouteProvider",
    }
  },
  base_table = "photos_image",
  data_table = "photos_image_field_data",
  revision_table = "photos_image_revision",
  revision_data_table = "photos_image_field_revision",
  translatable = TRUE,
  show_revision_ui = TRUE,
  entity_keys = {
    "id" = "id",
    "revision" = "revision_id",
    "label" = "title",
    "langcode" = "langcode",
    "uuid" = "uuid",
    "status" = "status",
    "published" = "status",
    "uid" = "uid",
    "owner" = "uid",
  },
  revision_metadata_keys = {
    "revision_user" = "revision_user",
    "revision_created" = "revision_created",
    "revision_log_message" = "revision_log_message",
  },
  admin_permission = "administer nodes",
  common_reference_target = TRUE,
  field_ui_base_route = "photos.admin",
  links = {
    "canonical" = "/photos/{node}/{photos_image}",
    "add-form" = "/photos/image/add",
    "collection" = "/admin/content/photos",
    "delete-form" = "/photos/{node}/{photos_image}/delete",
    "edit-form" = "/photos/{node}/{photos_image}/edit",
    "version-history" = "/photos/{node}/{photos_image}/revisions",
    "revision" = "/photos/{node}/{photos_image}/revisions/{photos_image_revision}/view",
  }
)

Hierarchy

Expanded class hierarchy of PhotosImage

See also

https://www.drupal.org/node/2006348.

4 files declare their use of PhotosImage
PhotosAccessTest.php in photos_access/tests/src/Functional/PhotosAccessTest.php
PhotosImageCover.php in src/Plugin/views/field/PhotosImageCover.php
PhotosImageSearch.php in src/Plugin/Search/PhotosImageSearch.php
PhotosUpload.php in src/PhotosUpload.php

File

src/Entity/PhotosImage.php, line 87

Namespace

Drupal\photos\Entity
View source
class PhotosImage extends EditorialContentEntityBase implements PhotosImageInterface {

  // @todo revision ui @see node.
  use EntityOwnerTrait;
  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
  public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);
    foreach (array_keys($this
      ->getTranslationLanguages()) as $langcode) {
      $translation = $this
        ->getTranslation($langcode);

      // If no owner has been set explicitly, make the anonymous user the owner.
      if (!$translation
        ->getOwner()) {
        $translation
          ->setOwnerId(0);
      }
    }

    // If no revision author has been set explicitly, make the image owner the
    // revision author.
    if (!$this
      ->getRevisionUser()) {
      $this
        ->setRevisionUserId($this
        ->getOwnerId());
    }

    // @todo check media and look into creating thumbnails and any other
    // derivatives.
  }

  /**
   * {@inheritdoc}
   */
  public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
    parent::preSaveRevision($storage, $record);
    $is_new_revision = $this
      ->isNewRevision();
    if (!$is_new_revision && isset($this->original) && empty($record->revision_log_message)) {

      // If we are updating an existing media item without adding a
      // new revision, we need to make sure $entity->revision_log_message is
      // reset whenever it is empty.
      // Therefore, this code allows us to avoid clobbering an existing log
      // entry with an empty one.
      $record->revision_log_message = $this->original->revision_log_message->value;
    }
    if ($is_new_revision) {
      $record->revision_created = self::getRequestTime();
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    parent::preDelete($storage, $entities);

    // @see PhotosImageFile::delete.
    // @todo move count updates to entity delete form?
    foreach ($entities as $entity) {
      $album_id = $entity
        ->getAlbumId();

      // Clear cache.
      Cache::invalidateTags([
        'node:' . $album_id,
        'photos:album:' . $album_id,
      ]);
      Cache::invalidateTags([
        'photos:image:' . $entity
          ->id(),
      ]);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getFids() {
    $fids = [];
    $photosImageFields = \Drupal::service('entity_field.manager')
      ->getFieldDefinitions('photos_image', 'photos_image');

    // @todo warn if other unhandled fields exist?
    foreach ($photosImageFields as $key => $field) {

      /** @var \Drupal\Core\Field\FieldDefinitionInterface $field */
      $fieldType = $field
        ->getType();
      if ($fieldType == 'file' || $fieldType == 'image') {

        // Check image and file fields.
        foreach ($this->{$key} as $item) {
          $fids[$item->entity
            ->id()] = $item->entity
            ->id();
        }
      }
      elseif ($fieldType == 'entity_reference') {

        // Check media fields.
        $settings = $field
          ->getSettings();
        if ($settings['target_type'] == 'media') {
          foreach ($this->{$key} as $item) {
            $media = Media::load($item->entity
              ->id());

            // @todo maybe getSourceFieldDefinition here?
            $fid = $media
              ->getSource()
              ->getSourceFieldValue($media);
            $fids[$fid] = $fid;
          }
        }
      }
    }
    return $fids;
  }

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

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

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

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

  /**
   * {@inheritdoc}
   */
  public function getFormat() {
    return $this
      ->get('description')->format;
  }

  /**
   * {@inheritdoc}
   */
  public function setFormat($format) {
    $this
      ->get('description')->format = $format;
    return $this;
  }

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

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

  /**
   * {@inheritdoc}
   */
  public function getAlbumUrl() {
    $album_link_override = \Drupal::config('photos.settings')
      ->get('album_link_override');
    if ($album_link_override) {
      $album_link_override = str_replace(':', '.', $album_link_override);

      // @todo add support for other arguments?
      $url = Url::fromRoute('view.' . $album_link_override, [
        'node' => $this
          ->getAlbumId(),
      ]);
    }
    else {

      // Default to the photo album node page.
      $url = Url::fromRoute('entity.node.canonical', [
        'node' => $this
          ->getAlbumId(),
      ]);
    }
    return $url;
  }

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

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

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

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

  /**
   * Gets an array of placeholders for this entity.
   *
   * Individual entity classes may override this method to add additional
   * placeholders if desired. If so, they should be sure to replicate the
   * property caching logic.
   *
   * @param string $rel
   *   The link relationship type, for example: canonical or edit-form.
   *
   * @return array
   *   An array of URI placeholders.
   */
  protected function urlRouteParameters($rel) {
    $uri_route_parameters = [];
    if (!in_array($rel, [
      'collection',
      'add-page',
      'add-form',
    ], TRUE)) {

      // The entity ID is needed as a route parameter.
      $uri_route_parameters[$this
        ->getEntityTypeId()] = $this
        ->id();

      // Include album node ID.
      $uri_route_parameters['node'] = $this
        ->getAlbumId();
    }
    if ($rel === 'add-form' && $this
      ->getEntityType()
      ->hasKey('bundle')) {
      $parameter_name = $this
        ->getEntityType()
        ->getBundleEntityType() ?: $this
        ->getEntityType()
        ->getKey('bundle');
      $uri_route_parameters[$parameter_name] = $this
        ->bundle();
    }
    if ($rel === 'revision' && $this instanceof RevisionableInterface) {
      $uri_route_parameters[$this
        ->getEntityTypeId() . '_revision'] = $this
        ->getRevisionId();
    }
    return $uri_route_parameters;
  }

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields += static::ownerBaseFieldDefinitions($entity_type);
    $fields['title'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Title'))
      ->setDescription(t('The image title.'))
      ->setRequired(TRUE)
      ->setTranslatable(TRUE)
      ->setRevisionable(TRUE)
      ->setSetting('max_length', 255)
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'string',
      'weight' => -5,
    ])
      ->setDisplayOptions('form', [
      'type' => 'string_textfield',
      'weight' => -5,
    ])
      ->setDisplayConfigurable('form', TRUE);

    // @todo migrate fid to new field_image field.
    // @todo Add an admin setting to select default image or file field for
    // upload form? Check if field exists when upload form loads. OR display
    // message to add field_image to photos_image to enable the upload form?
    $fields['description'] = BaseFieldDefinition::create('text_long')
      ->setLabel(t('Description'))
      ->setDescription(t('The image description field.'))
      ->setTranslatable(TRUE)
      ->setRevisionable(TRUE)
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'text_default',
      'weight' => 1,
    ])
      ->setDisplayConfigurable('view', TRUE)
      ->setDisplayOptions('form', [
      'type' => 'text_textfield',
      'weight' => 1,
    ])
      ->setDisplayConfigurable('form', TRUE);

    // @todo look at media thumbnail to use for album cover.
    // @todo get default image style from config settings (or field settings).
    $fields['uid']
      ->setLabel(t('Authored by'))
      ->setDescription(t('The username of the author.'))
      ->setRevisionable(TRUE)
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'author',
      'weight' => -3,
    ])
      ->setDisplayConfigurable('view', TRUE)
      ->setDisplayOptions('form', [
      'type' => 'entity_reference_autocomplete',
      'weight' => 4,
      'settings' => [
        'match_operator' => 'CONTAINS',
        'size' => '60',
        'placeholder' => '',
      ],
    ])
      ->setDisplayConfigurable('form', TRUE);
    $fields['created'] = BaseFieldDefinition::create('created')
      ->setLabel(t('Authored on'))
      ->setDescription(t('The time that the image was created.'))
      ->setRevisionable(TRUE)
      ->setTranslatable(TRUE)
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'timestamp',
      'weight' => -2,
    ])
      ->setDisplayConfigurable('view', TRUE)
      ->setDisplayOptions('form', [
      'type' => 'datetime_timestamp',
      'weight' => 5,
    ])
      ->setDisplayConfigurable('form', TRUE);

    // @todo target_type photos_album if entity is used for album.
    $fields['album_id'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Album ID'))
      ->setDescription(t('The album node ID.'))
      ->setRequired(TRUE)
      ->setRevisionable(TRUE)
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'entity_reference_label',
      'weight' => -1,
    ])
      ->setDisplayConfigurable('view', TRUE)
      ->setDisplayOptions('form', [
      'type' => 'entity_reference_autocomplete',
      'weight' => 3,
      'settings' => [
        'match_operator' => 'CONTAINS',
        'size' => '60',
        'placeholder' => '',
      ],
    ])
      ->setSetting('target_type', 'node')
      ->setDisplayConfigurable('form', TRUE);
    $fields['status']
      ->setDisplayOptions('form', [
      'type' => 'boolean_checkbox',
      'settings' => [
        'display_label' => TRUE,
      ],
      'weight' => 120,
    ])
      ->setDisplayConfigurable('form', TRUE);
    $fields['weight'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Weight'))
      ->setDescription(t('The image weight for custom sort order.'))
      ->setDefaultValue(0)
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'number_integer',
    ])
      ->setDisplayConfigurable('view', TRUE)
      ->setDisplayOptions('form', [
      'type' => 'number',
      'weight' => 20,
    ])
      ->setDisplayConfigurable('form', TRUE);
    $fields['changed'] = BaseFieldDefinition::create('changed')
      ->setLabel(t('Changed'))
      ->setDescription(t('The time that the image was last edited.'))
      ->setRevisionable(TRUE)
      ->setTranslatable(TRUE);
    return $fields;
  }

  /**
   * {@inheritdoc}
   */
  public static function getRequestTime() {
    return \Drupal::time()
      ->getRequestTime();
  }

  /**
   * {@inheritdoc}
   */
  public function getPager($id, $type = 'album_id') {
    $entity_id = $this
      ->id();
    $db = \Drupal::database();
    $query = $db
      ->select('photos_image_field_data', 'p');
    $query
      ->innerJoin('node_field_data', 'n', 'n.nid = p.album_id');
    $query
      ->fields('p', [
      'id',
      'album_id',
    ]);
    $query
      ->fields('n', [
      'title',
    ]);

    // Default order by id.
    $order = [
      'column' => 'p.id',
      'sort' => 'DESC',
    ];
    if ($type == 'album_id') {

      // Viewing album.
      // Order images by album settings.
      $album_data = $db
        ->query('SELECT data FROM {photos_album} WHERE album_id = :album_id', [
        ':album_id' => $id,
      ])
        ->fetchField();

      // @todo look into core serialization API.
      // @see https://www.drupal.org/docs/8/api/serialization-api/serialization-api-overview
      $album_data = unserialize($album_data);
      $default_order = \Drupal::config('photos.settings')
        ->get('photos_display_imageorder');
      $image_order = isset($album_data['imageorder']) ? $album_data['imageorder'] : $default_order;
      $order = explode('|', $image_order);
      $order = PhotosAlbum::orderValueChange($order[0], $order[1]);
      $query
        ->condition('p.album_id', $id);
    }
    elseif ($type == 'uid') {

      // Viewing all user images.
      $query
        ->condition('p.uid', $id);
    }
    $query
      ->orderBy($order['column'], $order['sort']);
    if ($order['column'] != 'p.id') {
      $query
        ->orderBy('p.id', 'DESC');
    }
    $results = $query
      ->execute();
    $stop = $pager['prev'] = $pager['next'] = 0;
    $num = 0;

    // @todo use view mode.
    $previousImageId = NULL;
    $photosImageStorage = \Drupal::entityTypeManager()
      ->getStorage('photos_image');
    $photosImageViewBuilder = \Drupal::entityTypeManager()
      ->getViewBuilder('photos_image');
    foreach ($results as $result) {
      $num++;

      // @todo new pager display view mode.
      if ($stop == 1) {
        $photosImage = $photosImageStorage
          ->load($result->id);
        $image_view = $photosImageViewBuilder
          ->view($photosImage, 'pager');
        $pager['nextView'] = $image_view;

        // Next image.
        $pager['nextUrl'] = Url::fromRoute('entity.photos_image.canonical', [
          'node' => $result->album_id,
          'photos_image' => $photosImage
            ->id(),
        ])
          ->toString();
        break;
      }
      if ($result->id == $entity_id) {
        $photosImage = $photosImageStorage
          ->load($result->id);
        $image_view = $photosImageViewBuilder
          ->view($photosImage, 'pager');
        $pager['currentView'] = $image_view;
        $stop = 1;
      }
      else {
        $previousImageId = $result->id;
      }
      $pager['albumTitle'] = $result->title;
    }
    if ($previousImageId) {
      $photosImage = $photosImageStorage
        ->load($previousImageId);
      $image_view = $photosImageViewBuilder
        ->view($photosImage, 'pager');
      $pager['prevView'] = $image_view;

      // Previous image.
      $pager['prevUrl'] = Url::fromRoute('entity.photos_image.canonical', [
        'node' => $id,
        'photos_image' => $photosImage
          ->id(),
      ])
        ->toString();
    }

    // @todo theme photos_pager with options for image and no-image.
    return $pager;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
ContentEntityBase::$activeLangcode protected property Language code identifying the entity active language.
ContentEntityBase::$defaultLangcode protected property Local cache for the default language code.
ContentEntityBase::$defaultLangcodeKey protected property The default langcode entity key.
ContentEntityBase::$enforceRevisionTranslationAffected protected property Whether the revision translation affected flag has been enforced.
ContentEntityBase::$entityKeys protected property Holds untranslatable entity keys such as the ID, bundle, and revision ID.
ContentEntityBase::$fieldDefinitions protected property Local cache for field definitions.
ContentEntityBase::$fields protected property The array of fields, each being an instance of FieldItemListInterface.
ContentEntityBase::$fieldsToSkipFromTranslationChangesCheck protected static property Local cache for fields to skip from the checking for translation changes.
ContentEntityBase::$isDefaultRevision protected property Indicates whether this is the default revision.
ContentEntityBase::$langcodeKey protected property The language entity key.
ContentEntityBase::$languages protected property Local cache for the available language objects.
ContentEntityBase::$loadedRevisionId protected property The loaded revision ID before the new revision was set.
ContentEntityBase::$newRevision protected property Boolean indicating whether a new revision should be created on save.
ContentEntityBase::$revisionTranslationAffectedKey protected property The revision translation affected entity key.
ContentEntityBase::$translatableEntityKeys protected property Holds translatable entity keys such as the label.
ContentEntityBase::$translationInitialize protected property A flag indicating whether a translation object is being initialized.
ContentEntityBase::$translations protected property An array of entity translation metadata.
ContentEntityBase::$validated protected property Whether entity validation was performed.
ContentEntityBase::$validationRequired protected property Whether entity validation is required before saving the entity.
ContentEntityBase::$values protected property The plain data values of the contained fields.
ContentEntityBase::access public function Checks data value access. Overrides EntityBase::access 1
ContentEntityBase::addTranslation public function Adds a new translation to the translatable object. Overrides TranslatableInterface::addTranslation
ContentEntityBase::bundle public function Gets the bundle of the entity. Overrides EntityBase::bundle
ContentEntityBase::bundleFieldDefinitions public static function Provides field definitions for a specific bundle. Overrides FieldableEntityInterface::bundleFieldDefinitions 4
ContentEntityBase::clearTranslationCache protected function Clear entity translation object cache to remove stale references.
ContentEntityBase::createDuplicate public function Creates a duplicate of the entity. Overrides EntityBase::createDuplicate 1
ContentEntityBase::get public function Gets a field item list. Overrides FieldableEntityInterface::get
ContentEntityBase::getEntityKey protected function Gets the value of the given entity key, if defined. 1
ContentEntityBase::getFieldDefinition public function Gets the definition of a contained field. Overrides FieldableEntityInterface::getFieldDefinition
ContentEntityBase::getFieldDefinitions public function Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface::getFieldDefinitions
ContentEntityBase::getFields public function Gets an array of all field item lists. Overrides FieldableEntityInterface::getFields
ContentEntityBase::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip in ::hasTranslationChanges. 1
ContentEntityBase::getIterator public function
ContentEntityBase::getLanguages protected function
ContentEntityBase::getLoadedRevisionId public function Gets the loaded Revision ID of the entity. Overrides RevisionableInterface::getLoadedRevisionId
ContentEntityBase::getRevisionId public function Gets the revision identifier of the entity. Overrides RevisionableInterface::getRevisionId
ContentEntityBase::getTranslatableFields public function Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface::getTranslatableFields
ContentEntityBase::getTranslatedField protected function Gets a translated field.
ContentEntityBase::getTranslation public function Gets a translation of the data. Overrides TranslatableInterface::getTranslation
ContentEntityBase::getTranslationLanguages public function Returns the languages the data is translated to. Overrides TranslatableInterface::getTranslationLanguages
ContentEntityBase::getTranslationStatus public function Returns the translation status. Overrides TranslationStatusInterface::getTranslationStatus
ContentEntityBase::getUntranslated public function Returns the translatable object referring to the original language. Overrides TranslatableInterface::getUntranslated
ContentEntityBase::hasField public function Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface::hasField
ContentEntityBase::hasTranslation public function Checks there is a translation for the given language code. Overrides TranslatableInterface::hasTranslation
ContentEntityBase::hasTranslationChanges public function Determines if the current translation of the entity has unsaved changes. Overrides TranslatableInterface::hasTranslationChanges
ContentEntityBase::id public function Gets the identifier. Overrides EntityBase::id
ContentEntityBase::initializeTranslation protected function Instantiates a translation object for an existing translation.
ContentEntityBase::isDefaultRevision public function Checks if this entity is the default revision. Overrides RevisionableInterface::isDefaultRevision
ContentEntityBase::isDefaultTranslation public function Checks whether the translation is the default one. Overrides TranslatableInterface::isDefaultTranslation
ContentEntityBase::isDefaultTranslationAffectedOnly public function Checks if untranslatable fields should affect only the default translation. Overrides TranslatableRevisionableInterface::isDefaultTranslationAffectedOnly
ContentEntityBase::isLatestRevision public function Checks if this entity is the latest revision. Overrides RevisionableInterface::isLatestRevision
ContentEntityBase::isLatestTranslationAffectedRevision public function Checks whether this is the latest revision affecting this translation. Overrides TranslatableRevisionableInterface::isLatestTranslationAffectedRevision
ContentEntityBase::isNewRevision public function Determines whether a new revision should be created on save. Overrides RevisionableInterface::isNewRevision
ContentEntityBase::isNewTranslation public function Checks whether the translation is new. Overrides TranslatableInterface::isNewTranslation
ContentEntityBase::isRevisionTranslationAffected public function Checks whether the current translation is affected by the current revision. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffected
ContentEntityBase::isRevisionTranslationAffectedEnforced public function Checks if the revision translation affected flag value has been enforced. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffectedEnforced
ContentEntityBase::isTranslatable public function Returns the translation support status. Overrides TranslatableInterface::isTranslatable
ContentEntityBase::isValidationRequired public function Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::isValidationRequired
ContentEntityBase::label public function Gets the label of the entity. Overrides EntityBase::label 6
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 9
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 1
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
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 2
DependencySerializationTrait::__wakeup public function 2
EntityBase::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
EntityBase::$entityTypeId protected property The entity type.
EntityBase::$typedData protected property A typed data object wrapping this entity.
EntityBase::create public static function Constructs a new entity object, without permanently saving it. Overrides EntityInterface::create
EntityBase::delete public function Deletes an entity permanently. Overrides EntityInterface::delete 2
EntityBase::enforceIsNew public function Enforces an entity to be new. Overrides EntityInterface::enforceIsNew
EntityBase::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 4
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::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::linkTemplates protected function Gets an array link templates. 1
EntityBase::load public static function Loads an entity. Overrides EntityInterface::load
EntityBase::loadMultiple public static function Loads one or more entities. Overrides EntityInterface::loadMultiple
EntityBase::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface::postDelete 18
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 7
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::uuidGenerator protected function Gets the UUID generator.
EntityChangedTrait::getChangedTime public function Gets the timestamp of the last entity change for the current translation.
EntityChangedTrait::getChangedTimeAcrossTranslations public function Returns the timestamp of the last entity change across all translations.
EntityChangedTrait::setChangedTime public function Sets the timestamp of the last entity change for the current translation.
EntityChangesDetectionTrait::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip when checking for changes. Aliased as: traitGetFieldsToSkipFromTranslationChangesCheck
EntityOwnerTrait::getDefaultEntityOwner public static function Default value callback for 'owner' base field. 1
EntityOwnerTrait::getOwner public function 1
EntityOwnerTrait::getOwnerId public function
EntityOwnerTrait::ownerBaseFieldDefinitions public static function Returns an array of base field definitions for entity owners.
EntityOwnerTrait::setOwner public function
EntityOwnerTrait::setOwnerId public function
EntityPublishedTrait::isPublished public function
EntityPublishedTrait::publishedBaseFieldDefinitions public static function Returns an array of base field definitions for publishing status.
EntityPublishedTrait::setPublished public function
EntityPublishedTrait::setUnpublished public function
PhotosImage::baseFieldDefinitions public static function Provides base field definitions for an entity type. Overrides EditorialContentEntityBase::baseFieldDefinitions
PhotosImage::getAlbumId public function Gets the image album id. Overrides PhotosImageInterface::getAlbumId
PhotosImage::getAlbumUrl public function Gets the album url. Overrides PhotosImageInterface::getAlbumUrl
PhotosImage::getCreatedTime public function Gets the image creation timestamp. Overrides PhotosImageInterface::getCreatedTime
PhotosImage::getDescription public function Gets the image description. Overrides PhotosImageInterface::getDescription
PhotosImage::getFids public function Gets the image file ids. Overrides PhotosImageInterface::getFids
PhotosImage::getFormat public function Gets the text format name for the image description. Overrides PhotosImageInterface::getFormat
PhotosImage::getPager public function Gets the page for this image. Overrides PhotosImageInterface::getPager
PhotosImage::getRequestTime public static function
PhotosImage::getTitle public function Gets the image title. Overrides PhotosImageInterface::getTitle
PhotosImage::getWeight public function Gets the image weight. Overrides PhotosImageInterface::getWeight
PhotosImage::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides EntityBase::preDelete
PhotosImage::preSave public function Acts on an entity before the presave hook is invoked. Overrides ContentEntityBase::preSave
PhotosImage::preSaveRevision public function Acts on a revision before it gets saved. Overrides ContentEntityBase::preSaveRevision
PhotosImage::setAlbumId public function Sets the image album id. Overrides PhotosImageInterface::setAlbumId
PhotosImage::setCreatedTime public function Sets the image creation timestamp. Overrides PhotosImageInterface::setCreatedTime
PhotosImage::setDescription public function Sets the image description. Overrides PhotosImageInterface::setDescription
PhotosImage::setFormat public function Sets the text format name for the image description. Overrides PhotosImageInterface::setFormat
PhotosImage::setTitle public function Sets the image title. Overrides PhotosImageInterface::setTitle
PhotosImage::setWeight public function Sets the image weight for custom sorting. Overrides PhotosImageInterface::setWeight
PhotosImage::urlRouteParameters protected function Gets an array of placeholders for this entity. Overrides EntityBase::urlRouteParameters
PhotosImageInterface::NOT_PUBLISHED constant Denotes that the image is not published.
PhotosImageInterface::PUBLISHED constant Denotes that the image is published.
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
RevisionLogEntityTrait::getEntityType abstract public function Gets the entity type definition.
RevisionLogEntityTrait::getRevisionCreationTime public function Implements \Drupal\Core\Entity\RevisionLogInterface::getRevisionCreationTime(). 1
RevisionLogEntityTrait::getRevisionLogMessage public function Implements \Drupal\Core\Entity\RevisionLogInterface::getRevisionLogMessage(). 1
RevisionLogEntityTrait::getRevisionMetadataKey protected static function Gets the name of a revision metadata field.
RevisionLogEntityTrait::getRevisionUser public function Implements \Drupal\Core\Entity\RevisionLogInterface::getRevisionUser(). 1
RevisionLogEntityTrait::getRevisionUserId public function Implements \Drupal\Core\Entity\RevisionLogInterface::getRevisionUserId(). 1
RevisionLogEntityTrait::revisionLogBaseFieldDefinitions public static function Provides revision-related base field definitions for an entity type.
RevisionLogEntityTrait::setRevisionCreationTime public function Implements \Drupal\Core\Entity\RevisionLogInterface::setRevisionCreationTime(). 1
RevisionLogEntityTrait::setRevisionLogMessage public function Implements \Drupal\Core\Entity\RevisionLogInterface::setRevisionLogMessage(). 1
RevisionLogEntityTrait::setRevisionUser public function Implements \Drupal\Core\Entity\RevisionLogInterface::setRevisionUser(). 1
RevisionLogEntityTrait::setRevisionUserId public function Implements \Drupal\Core\Entity\RevisionLogInterface::setRevisionUserId(). 1
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
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.