You are here

class Wishlist in Commerce Wishlist 8.3

Defines the wishlist entity class.

Plugin annotation


@ContentEntityType(
  id = "commerce_wishlist",
  label = @Translation("Wishlist"),
  label_collection = @Translation("Wishlists"),
  label_singular = @Translation("wishlist"),
  label_plural = @Translation("wishlists"),
  label_count = @PluralTranslation(
    singular = "@count wishlist",
    plural = "@count wishlists",
  ),
  bundle_label = @Translation("Wishlist type"),
  handlers = {
    "event" = "Drupal\commerce_wishlist\Event\WishlistEvent",
    "storage" = "Drupal\commerce_wishlist\WishlistStorage",
    "access" = "Drupal\entity\UncacheableEntityAccessControlHandler",
    "query_access" = "Drupal\entity\QueryAccess\UncacheableQueryAccessHandler",
    "permission_provider" = "Drupal\entity\UncacheableEntityPermissionProvider",
    "list_builder" = "Drupal\commerce_wishlist\WishlistListBuilder",
    "views_data" = "Drupal\commerce\CommerceEntityViewsData",
    "form" = {
      "default" = "Drupal\commerce_wishlist\Form\WishlistForm",
      "add" = "Drupal\commerce_wishlist\Form\WishlistForm",
      "edit" = "Drupal\commerce_wishlist\Form\WishlistForm",
      "duplicate" = "Drupal\commerce_wishlist\Form\WishlistForm",
      "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm",
      "user" = "Drupal\commerce_wishlist\Form\WishlistUserForm",
      "share" = "Drupal\commerce_wishlist\Form\WishlistShareForm",
    },
    "local_task_provider" = {
      "default" = "Drupal\entity\Menu\DefaultEntityLocalTaskProvider",
    },
    "route_provider" = {
      "default" = "Drupal\commerce_wishlist\WishlistRouteProvider",
      "delete-multiple" = "Drupal\entity\Routing\DeleteMultipleRouteProvider",
    },
  },
  base_table = "commerce_wishlist",
  admin_permission = "administer commerce_wishlist",
  permission_granularity = "bundle",
  fieldable = TRUE,
  entity_keys = {
    "id" = "wishlist_id",
    "label" = "name",
    "uuid" = "uuid",
    "bundle" = "type",
    "uid" = "uid",
    "owner" = "uid",
  },
  links = {
    "add-page" = "/admin/commerce/wishlists/add",
    "add-form" = "/admin/commerce/wishlists/add/{commerce_wishlist_type}",
    "edit-form" = "/admin/commerce/wishlists/{commerce_wishlist}/edit",
    "duplicate-form" = "/admin/commerce/wishlists/{commerce_wishlist}/duplicate",
    "delete-form" = "/admin/commerce/wishlists/{commerce_wishlist}/delete",
    "delete-multiple-form" = "/admin/commerce/wishlists/delete",
    "collection" = "/admin/commerce/wishlists",
    "user-form" = "/user/{user}/wishlist/{code}",
    "share-form" = "/user/{user}/wishlist/{code}/share",
  },
  bundle_entity_type = "commerce_wishlist_type",
  field_ui_base_route = "entity.commerce_wishlist_type.edit_form"
)

Hierarchy

Expanded class hierarchy of Wishlist

9 files declare their use of Wishlist
WishlistAnonymousTest.php in tests/src/FunctionalJavascript/WishlistAnonymousTest.php
WishlistAssignmentTest.php in tests/src/Kernel/WishlistAssignmentTest.php
WishlistItemAccessTest.php in tests/src/Kernel/WishlistItemAccessTest.php
WishlistItemDeleteTest.php in tests/src/Kernel/QueueWorker/WishlistItemDeleteTest.php
WishlistItemTest.php in tests/src/Kernel/Entity/WishlistItemTest.php

... See full list

4 string references to 'Wishlist'
commerce_wishlist.links.task.yml in ./commerce_wishlist.links.task.yml
commerce_wishlist.links.task.yml
commerce_wishlist.routing.yml in ./commerce_wishlist.routing.yml
commerce_wishlist.routing.yml
core.entity_view_mode.commerce_product_variation.wishlist.yml in config/optional/core.entity_view_mode.commerce_product_variation.wishlist.yml
config/optional/core.entity_view_mode.commerce_product_variation.wishlist.yml
WishlistProvider::createWishlist in src/WishlistProvider.php
Creates a wishlist entity for the given user.

File

src/Entity/Wishlist.php, line 81

Namespace

Drupal\commerce_wishlist\Entity
View source
class Wishlist extends ContentEntityBase implements WishlistInterface {
  use EntityChangedTrait;
  use EntityOwnerTrait;

  /**
   * {@inheritdoc}
   */
  public function createDuplicate() {
    $duplicate = parent::createDuplicate();

    // Unique code cannot be transferred because their codes are unique.
    $duplicate
      ->set('code', NULL);

    // We don't duplicate wishlist items.
    $duplicate
      ->set('wishlist_items', []);
    return $duplicate;
  }

  /**
   * {@inheritdoc}
   */
  public function toUrl($rel = 'canonical', array $options = []) {

    // Can't declare "canonical" as a link template because it requires a
    // custom parameter, which breaks contribs that don't expect it.
    // StringFormatter assumes 'revision' is always a valid link template.
    if (in_array($rel, [
      'canonical',
      'revision',
    ])) {
      $route_name = 'entity.commerce_wishlist.canonical';
      $route_parameters = [
        'code' => $this
          ->getCode(),
      ];
      $options += [
        'entity_type' => 'commerce_wishlist',
        'entity' => $this,
        // Display links by default based on the current language.
        'language' => $this
          ->language(),
      ];
      return new Url($route_name, $route_parameters, $options);
    }
    else {
      return parent::toUrl($rel, $options);
    }
  }

  /**
   * {@inheritdoc}
   */
  protected function urlRouteParameters($rel) {
    if (in_array($rel, [
      'user-form',
      'share-form',
    ])) {
      return [
        'user' => $this
          ->getOwnerId(),
        'code' => $this
          ->getCode(),
      ];
    }
    else {
      return parent::urlRouteParameters($rel);
    }
  }

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

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

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

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

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

  /**
   * {@inheritdoc}
   */
  public function setShippingProfile(ProfileInterface $profile) {
    $this
      ->set('shipping_profile', $profile);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getItems() {
    return $this
      ->get('wishlist_items')
      ->referencedEntities();
  }

  /**
   * {@inheritdoc}
   */
  public function setItems(array $wishlist_items) {
    $this
      ->set('wishlist_items', $wishlist_items);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function hasItems() {
    return !$this
      ->get('wishlist_items')
      ->isEmpty();
  }

  /**
   * {@inheritdoc}
   */
  public function addItem(WishlistItemInterface $wishlist_item) {
    if (!$this
      ->hasItem($wishlist_item)) {
      $this
        ->get('wishlist_items')
        ->appendItem($wishlist_item);
    }
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function removeItem(WishlistItemInterface $wishlist_item) {
    $index = $this
      ->getItemIndex($wishlist_item);
    if ($index !== FALSE) {
      $this
        ->get('wishlist_items')
        ->offsetUnset($index);
    }
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function hasItem(WishlistItemInterface $wishlist_item) {
    return $this
      ->getItemIndex($wishlist_item) !== FALSE;
  }

  /**
   * Gets the index of the given wishlist item.
   *
   * @param \Drupal\commerce_wishlist\Entity\WishlistItemInterface $wishlist_item
   *   The wishlist item.
   *
   * @return int|bool
   *   The index of the given wishlist item, or FALSE if not found.
   */
  protected function getItemIndex(WishlistItemInterface $wishlist_item) {
    $values = $this
      ->get('wishlist_items')
      ->getValue();
    $wishlist_item_ids = array_map(function ($value) {
      return $value['target_id'];
    }, $values);
    return array_search($wishlist_item
      ->id(), $wishlist_item_ids);
  }

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

  /**
   * {@inheritdoc}
   */
  public function setDefault($default) {
    $this
      ->set('is_default', (bool) $default);
    return $this;
  }

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

  /**
   * {@inheritdoc}
   */
  public function setPublic($public) {
    $this
      ->set('is_public', (bool) $public);
    return $this;
  }

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

  /**
   * {@inheritdoc}
   */
  public function setKeepPurchasedItems($keep_purchased_items) {
    $this
      ->set('keep_purchased_items', (bool) $keep_purchased_items);
    return $this;
  }

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

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

  /**
   * {@inheritdoc}
   */
  public function preSave(EntityStorageInterface $storage) {

    /** @var \Drupal\commerce_wishlist\WishlistStorageInterface $storage */
    parent::preSave($storage);
    if ($this
      ->get('code')
      ->isEmpty()) {

      /** @var \Drupal\commerce_wishlist\WishlistStorageInterface $storage */
      $storage = $this
        ->entityTypeManager()
        ->getStorage('commerce_wishlist');
      $random = new Random();
      $code = $random
        ->word(13);

      // Ensure code uniqueness. Collisions are rare, but possible.
      while ($storage
        ->loadByCode($code)) {
        $code = $random
          ->word(13);
      }
      $this
        ->setCode($random
        ->word(13));
    }

    // Mark the wishlist as default if there's no other default.
    if ($this
      ->getOwnerId() && !$this
      ->isDefault()) {
      $wishlist = $storage
        ->loadDefaultByUser($this
        ->getOwner(), $this
        ->bundle());
      if (!$wishlist || !$wishlist
        ->isDefault()) {
        $this
          ->setDefault(TRUE);
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function postSave(EntityStorageInterface $storage, $update = TRUE) {

    /** @var \Drupal\commerce_wishlist\WishlistStorageInterface $storage */
    parent::postSave($storage, $update);

    // Ensure there's a back-reference on each wishlist item.
    foreach ($this
      ->getItems() as $wishlist_item) {
      if ($wishlist_item->wishlist_id
        ->isEmpty()) {
        $wishlist_item->wishlist_id = $this
          ->id();
        $wishlist_item
          ->save();
      }
    }
    if ($this
      ->getOwnerId()) {
      $default = $this
        ->isDefault();
      $original_default = $this->original ? $this->original
        ->isDefault() : FALSE;
      if ($default && !$original_default) {
        $wishlists = $storage
          ->loadMultipleByUser($this
          ->getOwner(), $this
          ->bundle());
        foreach ($wishlists as $wishlist) {
          if ($wishlist
            ->id() != $this
            ->id() && $wishlist
            ->isDefault()) {
            $wishlist
              ->setDefault(FALSE);
            $wishlist
              ->save();
          }
        }
      }
    }
  }

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

    // Delete the wishlist items of a deleted wishlist.
    $wishlist_items = [];

    /** @var \Drupal\commerce_wishlist\Entity\WishlistInterface $entity */
    foreach ($entities as $entity) {
      foreach ($entity
        ->getItems() as $wishlist_item) {
        $wishlist_items[$wishlist_item
          ->id()] = $wishlist_item;
      }
    }

    /** @var \Drupal\commerce_wishlist\WishlistItemStorageInterface $wishlist_item_storage */
    $wishlist_item_storage = \Drupal::service('entity_type.manager')
      ->getStorage('commerce_wishlist_item');
    $wishlist_item_storage
      ->delete($wishlist_items);
  }

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields += static::ownerBaseFieldDefinitions($entity_type);
    $fields['code'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Code'))
      ->setDescription(t('The wishlist code.'))
      ->setSetting('max_length', 25)
      ->addConstraint('UniqueField', []);
    $fields['name'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Name'))
      ->setDescription(t('The wishlist name.'))
      ->setRequired(TRUE)
      ->setDefaultValue('')
      ->setSetting('max_length', 255)
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);
    $fields['uid']
      ->setLabel(t('Owner'))
      ->setDescription(t('The wishlist owner.'))
      ->setSetting('handler', 'default')
      ->setDisplayOptions('view', [
      'label' => 'above',
      'type' => 'author',
      'weight' => 0,
    ])
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);
    $fields['shipping_profile'] = BaseFieldDefinition::create('entity_reference_revisions')
      ->setLabel(t('Shipping profile'))
      ->setDescription(t('Shipping profile'))
      ->setSetting('target_type', 'profile')
      ->setSetting('handler', 'default')
      ->setSetting('handler_settings', [
      'target_bundles' => [
        'customer',
      ],
    ])
      ->setDisplayOptions('form', [
      'type' => 'options_select',
      'weight' => 0,
      'settings' => [],
    ])
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);
    $fields['wishlist_items'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Wishlist items'))
      ->setDescription(t('The wishlist items.'))
      ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
      ->setSetting('target_type', 'commerce_wishlist_item')
      ->setSetting('handler', 'default')
      ->setDisplayOptions('view', [
      'type' => 'commerce_wishlist_item_table',
      'weight' => 0,
    ])
      ->setDisplayConfigurable('form', FALSE)
      ->setDisplayConfigurable('view', TRUE);
    $fields['is_default'] = BaseFieldDefinition::create('boolean')
      ->setLabel(t('Default'))
      ->setDescription(t('A boolean indicating whether the wishlist is the default one.'));
    $fields['is_public'] = BaseFieldDefinition::create('boolean')
      ->setLabel(t('Public'))
      ->setDescription(t('Whether the wishlist is public.'))
      ->setDisplayOptions('form', [
      'type' => 'boolean_checkbox',
      'settings' => [
        'display_label' => TRUE,
      ],
      'weight' => 19,
    ])
      ->setDisplayConfigurable('form', TRUE);
    $fields['keep_purchased_items'] = BaseFieldDefinition::create('boolean')
      ->setLabel(t('Keep purchased items in the list'))
      ->setDescription(t('Whether items should remain in the wishlist once purchased.'))
      ->setDefaultValue(TRUE)
      ->setDisplayOptions('form', [
      'type' => 'boolean_checkbox',
      'settings' => [
        'display_label' => TRUE,
      ],
      'weight' => 20,
    ])
      ->setDisplayConfigurable('form', TRUE);
    $fields['created'] = BaseFieldDefinition::create('created')
      ->setLabel(t('Created'))
      ->setDescription(t('The time when the wishlist was created.'));
    $fields['changed'] = BaseFieldDefinition::create('changed')
      ->setLabel(t('Changed'))
      ->setDescription(t('The time when the wishlist was last edited.'));
    return $fields;
  }

}

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::get public function Gets a field item list. Overrides FieldableEntityInterface::get
ContentEntityBase::getEntityKey protected function Gets the value of the given entity key, if defined. 1
ContentEntityBase::getFieldDefinition public function Gets the definition of a contained field. Overrides FieldableEntityInterface::getFieldDefinition
ContentEntityBase::getFieldDefinitions public function Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface::getFieldDefinitions
ContentEntityBase::getFields public function Gets an array of all field item lists. Overrides FieldableEntityInterface::getFields
ContentEntityBase::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip in ::hasTranslationChanges. 1
ContentEntityBase::getIterator public function
ContentEntityBase::getLanguages protected function
ContentEntityBase::getLoadedRevisionId public function Gets the loaded Revision ID of the entity. Overrides RevisionableInterface::getLoadedRevisionId
ContentEntityBase::getRevisionId public function Gets the revision identifier of the entity. Overrides RevisionableInterface::getRevisionId
ContentEntityBase::getTranslatableFields public function Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface::getTranslatableFields
ContentEntityBase::getTranslatedField protected function Gets a translated field.
ContentEntityBase::getTranslation public function Gets a translation of the data. Overrides TranslatableInterface::getTranslation
ContentEntityBase::getTranslationLanguages public function Returns the languages the data is translated to. Overrides TranslatableInterface::getTranslationLanguages
ContentEntityBase::getTranslationStatus public function Returns the translation status. Overrides TranslationStatusInterface::getTranslationStatus
ContentEntityBase::getUntranslated public function Returns the translatable object referring to the original language. Overrides TranslatableInterface::getUntranslated
ContentEntityBase::hasField public function Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface::hasField
ContentEntityBase::hasTranslation public function Checks there is a translation for the given language code. Overrides TranslatableInterface::hasTranslation
ContentEntityBase::hasTranslationChanges public function Determines if the current translation of the entity has unsaved changes. Overrides TranslatableInterface::hasTranslationChanges
ContentEntityBase::id public function Gets the identifier. Overrides EntityBase::id
ContentEntityBase::initializeTranslation protected function Instantiates a translation object for an existing translation.
ContentEntityBase::isDefaultRevision public function Checks if this entity is the default revision. Overrides RevisionableInterface::isDefaultRevision
ContentEntityBase::isDefaultTranslation public function Checks whether the translation is the default one. Overrides TranslatableInterface::isDefaultTranslation
ContentEntityBase::isDefaultTranslationAffectedOnly public function Checks if untranslatable fields should affect only the default translation. Overrides TranslatableRevisionableInterface::isDefaultTranslationAffectedOnly
ContentEntityBase::isLatestRevision public function Checks if this entity is the latest revision. Overrides RevisionableInterface::isLatestRevision
ContentEntityBase::isLatestTranslationAffectedRevision public function Checks whether this is the latest revision affecting this translation. Overrides TranslatableRevisionableInterface::isLatestTranslationAffectedRevision
ContentEntityBase::isNewRevision public function Determines whether a new revision should be created on save. Overrides RevisionableInterface::isNewRevision
ContentEntityBase::isNewTranslation public function Checks whether the translation is new. Overrides TranslatableInterface::isNewTranslation
ContentEntityBase::isRevisionTranslationAffected public function Checks whether the current translation is affected by the current revision. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffected
ContentEntityBase::isRevisionTranslationAffectedEnforced public function Checks if the revision translation affected flag value has been enforced. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffectedEnforced
ContentEntityBase::isTranslatable public function Returns the translation support status. Overrides TranslatableInterface::isTranslatable
ContentEntityBase::isValidationRequired public function Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::isValidationRequired
ContentEntityBase::label public function Gets the label of the entity. Overrides EntityBase::label 2
ContentEntityBase::language public function Gets the language of the entity. Overrides EntityBase::language
ContentEntityBase::onChange public function Reacts to changes to a field. Overrides FieldableEntityInterface::onChange
ContentEntityBase::postCreate public function Acts on a created entity before hooks are invoked. Overrides EntityBase::postCreate
ContentEntityBase::preSaveRevision public function Acts on a revision before it gets saved. Overrides RevisionableInterface::preSaveRevision 2
ContentEntityBase::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityBase::referencedEntities 1
ContentEntityBase::removeTranslation public function Removes the translation identified by the given language code. Overrides TranslatableInterface::removeTranslation
ContentEntityBase::set public function Sets a field value. Overrides FieldableEntityInterface::set
ContentEntityBase::setDefaultLangcode protected function Populates the local cache for the default language code.
ContentEntityBase::setNewRevision public function Enforces an entity to be saved as a new revision. Overrides RevisionableInterface::setNewRevision
ContentEntityBase::setRevisionTranslationAffected public function Marks the current revision translation as affected. Overrides TranslatableRevisionableInterface::setRevisionTranslationAffected
ContentEntityBase::setRevisionTranslationAffectedEnforced public function Enforces the revision translation affected flag value. Overrides TranslatableRevisionableInterface::setRevisionTranslationAffectedEnforced
ContentEntityBase::setValidationRequired public function Sets whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::setValidationRequired
ContentEntityBase::toArray public function Gets an array of all property values. Overrides EntityBase::toArray
ContentEntityBase::updateFieldLangcodes protected function Updates language for already instantiated fields.
ContentEntityBase::updateLoadedRevisionId public function Updates the loaded Revision ID with the revision ID. Overrides RevisionableInterface::updateLoadedRevisionId
ContentEntityBase::updateOriginalValues public function Updates the original values with the interim changes.
ContentEntityBase::uuid public function Gets the entity UUID (Universally Unique Identifier). Overrides EntityBase::uuid
ContentEntityBase::validate public function Validates the currently set values. Overrides FieldableEntityInterface::validate
ContentEntityBase::wasDefaultRevision public function Checks whether the entity object was a default revision when it was saved. Overrides RevisionableInterface::wasDefaultRevision
ContentEntityBase::__clone public function Magic method: Implements a deep clone.
ContentEntityBase::__construct public function Constructs an Entity object. Overrides EntityBase::__construct
ContentEntityBase::__get public function Implements the magic method for getting object properties.
ContentEntityBase::__isset public function Implements the magic method for isset().
ContentEntityBase::__set public function Implements the magic method for setting object properties.
ContentEntityBase::__sleep public function Overrides EntityBase::__sleep
ContentEntityBase::__unset public function Implements the magic method for unset().
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 1
DependencySerializationTrait::__wakeup public function 2
EntityBase::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
EntityBase::$entityTypeId protected property The entity type.
EntityBase::$typedData protected property A typed data object wrapping this entity.
EntityBase::create public static function Constructs a new entity object, without permanently saving it. Overrides EntityInterface::create
EntityBase::delete public function Deletes an entity permanently. Overrides EntityInterface::delete 2
EntityBase::enforceIsNew public function Enforces an entity to be new. Overrides EntityInterface::enforceIsNew
EntityBase::entityManager Deprecated protected function Gets the entity manager.
EntityBase::entityTypeBundleInfo protected function Gets the entity type bundle info service.
EntityBase::entityTypeManager protected function Gets the entity type manager.
EntityBase::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
EntityBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
EntityBase::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags
EntityBase::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface::getCacheTagsToInvalidate 2
EntityBase::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. Overrides EntityInterface::getConfigDependencyKey
EntityBase::getConfigDependencyName public function Gets the configuration dependency name. Overrides EntityInterface::getConfigDependencyName 1
EntityBase::getConfigTarget public function Gets the configuration target identifier for the entity. Overrides EntityInterface::getConfigTarget 1
EntityBase::getEntityType public function Gets the entity type definition. Overrides EntityInterface::getEntityType
EntityBase::getEntityTypeId public function Gets the ID of the type of the entity. Overrides EntityInterface::getEntityTypeId
EntityBase::getListCacheTagsToInvalidate protected function The list cache tags to invalidate for this entity.
EntityBase::getOriginalId public function Gets the original ID. Overrides EntityInterface::getOriginalId 1
EntityBase::getTypedData public function Gets a typed data object for this entity object. Overrides EntityInterface::getTypedData
EntityBase::hasLinkTemplate public function Indicates if a link template exists for a given key. Overrides EntityInterface::hasLinkTemplate
EntityBase::invalidateTagsOnDelete protected static function Invalidates an entity's cache tags upon delete. 1
EntityBase::invalidateTagsOnSave protected function Invalidates an entity's cache tags upon save. 1
EntityBase::isNew public function Determines whether the entity is new. Overrides EntityInterface::isNew 2
EntityBase::languageManager protected function Gets the language manager.
EntityBase::link public function Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface::link 1
EntityBase::linkTemplates protected function Gets an array link templates. 1
EntityBase::load public static function Loads an entity. Overrides EntityInterface::load
EntityBase::loadMultiple public static function Loads one or more entities. Overrides EntityInterface::loadMultiple
EntityBase::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::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::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
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.
Wishlist::addItem public function Adds an wishlist item. Overrides WishlistInterface::addItem
Wishlist::baseFieldDefinitions public static function Provides base field definitions for an entity type. Overrides ContentEntityBase::baseFieldDefinitions
Wishlist::createDuplicate public function Creates a duplicate of the entity. Overrides ContentEntityBase::createDuplicate
Wishlist::getCode public function Gets the wishlist code. Overrides WishlistInterface::getCode
Wishlist::getCreatedTime public function Gets the wishlist creation timestamp. Overrides WishlistInterface::getCreatedTime
Wishlist::getItemIndex protected function Gets the index of the given wishlist item.
Wishlist::getItems public function Gets the wishlist items. Overrides WishlistInterface::getItems
Wishlist::getKeepPurchasedItems public function Gets whether items should remain in the wishlist once purchased. Overrides WishlistInterface::getKeepPurchasedItems
Wishlist::getName public function Gets the wishlist name. Overrides WishlistInterface::getName
Wishlist::getShippingProfile public function Gets the shipping profile. Overrides WishlistInterface::getShippingProfile
Wishlist::hasItem public function Checks whether the wishlist has a given wishlist item. Overrides WishlistInterface::hasItem
Wishlist::hasItems public function Gets whether the wishlist has wishlist items. Overrides WishlistInterface::hasItems
Wishlist::isDefault public function Gets whether this is the user's default wishlist. Overrides WishlistInterface::isDefault
Wishlist::isPublic public function Gets whether the wishlist is public. Overrides WishlistInterface::isPublic
Wishlist::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityBase::postDelete
Wishlist::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides ContentEntityBase::postSave
Wishlist::preSave public function Acts on an entity before the presave hook is invoked. Overrides ContentEntityBase::preSave
Wishlist::removeItem public function Removes an wishlist item. Overrides WishlistInterface::removeItem
Wishlist::setCode public function Sets the wishlist code. Overrides WishlistInterface::setCode
Wishlist::setCreatedTime public function Sets the wishlist creation timestamp. Overrides WishlistInterface::setCreatedTime
Wishlist::setDefault public function Sets whether this is the user's default wishlist. Overrides WishlistInterface::setDefault
Wishlist::setItems public function Sets the wishlist items. Overrides WishlistInterface::setItems
Wishlist::setKeepPurchasedItems public function Sets whether items should remain in the wishlist once purchased. Overrides WishlistInterface::setKeepPurchasedItems
Wishlist::setName public function Sets the wishlist name. Overrides WishlistInterface::setName
Wishlist::setPublic public function Sets whether the wishlist is public. Overrides WishlistInterface::setPublic
Wishlist::setShippingProfile public function Sets the shipping profile. Overrides WishlistInterface::setShippingProfile
Wishlist::toUrl public function Gets the URL object for the entity. Overrides EntityBase::toUrl
Wishlist::urlRouteParameters protected function Gets an array of placeholders for this entity. Overrides EntityBase::urlRouteParameters