class Shipment in Commerce Shipping 8.2
Defines the shipment entity class.
Plugin annotation
@ContentEntityType(
id = "commerce_shipment",
label = @Translation("Shipment"),
label_collection = @Translation("Shipments"),
label_singular = @Translation("shipment"),
label_plural = @Translation("shipments"),
label_count = @PluralTranslation(
singular = "@count shipment",
plural = "@count shipments",
),
bundle_label = @Translation("Shipment type"),
handlers = {
"event" = "Drupal\commerce_shipping\Event\ShipmentEvent",
"list_builder" = "Drupal\commerce_shipping\ShipmentListBuilder",
"storage" = "Drupal\commerce_shipping\ShipmentStorage",
"access" = "Drupal\commerce_shipping\ShipmentAccessControlHandler",
"permission_provider" = "Drupal\commerce_shipping\ShipmentPermissionProvider",
"views_data" = "Drupal\commerce\CommerceEntityViewsData",
"form" = {
"default" = "Drupal\commerce_shipping\Form\ShipmentForm",
"add" = "Drupal\commerce_shipping\Form\ShipmentForm",
"edit" = "Drupal\commerce_shipping\Form\ShipmentForm",
"delete" = "Drupal\Core\Entity\ContentEntityDeleteForm",
"resend-confirmation" = "Drupal\commerce_shipping\Form\ShipmentConfirmationResendForm",
},
"inline_form" = "Drupal\commerce_shipping\Form\ShipmentInlineForm",
"route_provider" = {
"default" = "Drupal\commerce_shipping\ShipmentRouteProvider",
},
},
base_table = "commerce_shipment",
admin_permission = "administer commerce_shipment",
fieldable = TRUE,
entity_keys = {
"id" = "shipment_id",
"bundle" = "type",
"label" = "title",
"uuid" = "uuid",
},
links = {
"canonical" = "/admin/commerce/orders/{commerce_order}/shipments/{commerce_shipment}",
"add-page" = "/admin/commerce/orders/{commerce_order}/shipments/add",
"collection" = "/admin/commerce/orders/{commerce_order}/shipments",
"add-form" = "/admin/commerce/orders/{commerce_order}/shipments/add/{commerce_shipment_type}",
"edit-form" = "/admin/commerce/orders/{commerce_order}/shipments/{commerce_shipment}/edit",
"delete-form" = "/admin/commerce/orders/{commerce_order}/shipments/{commerce_shipment}/delete",
"resend-confirmation-form" = "/admin/commerce/orders/{commerce_order}/shipments/{commerce_shipment}/resend-confirmation",
"state-transition-form" = "/admin/commerce/orders/{commerce_order}/shipments/{commerce_shipment}/{field_name}/{transition_id}"
},
bundle_entity_type = "commerce_shipment_type",
field_ui_base_route = "entity.commerce_shipment_type.edit_form",
)
Hierarchy
- class \Drupal\Core\Entity\EntityBase implements EntityInterface uses RefinableCacheableDependencyTrait, DependencySerializationTrait
- class \Drupal\Core\Entity\ContentEntityBase implements \Drupal\Core\Entity\IteratorAggregate, ContentEntityInterface, TranslationStatusInterface uses EntityChangesDetectionTrait, SynchronizableEntityTrait
- class \Drupal\commerce_shipping\Entity\Shipment implements ShipmentInterface uses EntityChangedTrait
- class \Drupal\Core\Entity\ContentEntityBase implements \Drupal\Core\Entity\IteratorAggregate, ContentEntityInterface, TranslationStatusInterface uses EntityChangesDetectionTrait, SynchronizableEntityTrait
Expanded class hierarchy of Shipment
13 files declare their use of Shipment
- FilterShippingMethodsEventTest.php in tests/
src/ Kernel/ FilterShippingMethodsEventTest.php - OrderShipmentSummaryTest.php in tests/
src/ Kernel/ OrderShipmentSummaryTest.php - OrderWorkflowTest.php in tests/
src/ Kernel/ OrderWorkflowTest.php - PromotionSubscriberTest.php in tests/
src/ Kernel/ EventSubscriber/ PromotionSubscriberTest.php - SerializationTest.php in tests/
src/ Kernel/ SerializationTest.php
16 string references to 'Shipment'
- commerce_shipping.workflow_groups.yml in ./
commerce_shipping.workflow_groups.yml - commerce_shipping.workflow_groups.yml
- FilterShippingMethodsEventTest::testEvent in tests/
src/ Kernel/ FilterShippingMethodsEventTest.php - Tests that the shipping method is removed.
- OrderShipmentSummaryTest::setUp in tests/
src/ Kernel/ OrderShipmentSummaryTest.php - OrderWorkflowTest::setUp in tests/
src/ Kernel/ OrderWorkflowTest.php - PromotionSubscriberTest::setUp in tests/
src/ Kernel/ EventSubscriber/ PromotionSubscriberTest.php
File
- src/
Entity/ Shipment.php, line 76
Namespace
Drupal\commerce_shipping\EntityView source
class Shipment extends ContentEntityBase implements ShipmentInterface {
use EntityChangedTrait;
/**
* {@inheritdoc}
*/
protected function urlRouteParameters($rel) {
$uri_route_parameters = parent::urlRouteParameters($rel);
$uri_route_parameters['commerce_order'] = $this
->getOrderId();
return $uri_route_parameters;
}
/**
* {@inheritdoc}
*/
public function clearRate() {
$fields = [
'amount',
'original_amount',
'shipping_method',
'shipping_service',
];
foreach ($fields as $field) {
$this
->set($field, NULL);
}
return $this;
}
/**
* {@inheritdoc}
*/
public function populateFromProposedShipment(ProposedShipment $proposed_shipment) {
if ($proposed_shipment
->getType() != $this
->bundle()) {
throw new \InvalidArgumentException(sprintf('The proposed shipment type "%s" does not match the shipment type "%s".', $proposed_shipment
->getType(), $this
->bundle()));
}
$this
->set('order_id', $proposed_shipment
->getOrderId());
$this
->set('title', $proposed_shipment
->getTitle());
$this
->set('items', $proposed_shipment
->getItems());
$this
->set('shipping_profile', $proposed_shipment
->getShippingProfile());
$this
->set('package_type', $proposed_shipment
->getPackageTypeId());
foreach ($proposed_shipment
->getCustomFields() as $field_name => $value) {
if ($this
->hasField($field_name)) {
$this
->set($field_name, $value);
}
else {
$this
->setData($field_name, $value);
}
}
$this
->prepareFields();
}
/**
* {@inheritdoc}
*/
public function getOrder() {
return $this
->get('order_id')->entity;
}
/**
* {@inheritdoc}
*/
public function getOrderId() {
return $this
->get('order_id')->target_id;
}
/**
* {@inheritdoc}
*/
public function getPackageType() {
if (!$this
->get('package_type')
->isEmpty()) {
$package_type_id = $this
->get('package_type')->value;
$package_type_manager = \Drupal::service('plugin.manager.commerce_package_type');
return $package_type_manager
->createInstance($package_type_id);
}
}
/**
* {@inheritdoc}
*/
public function setPackageType(PackageTypePluginInterface $package_type) {
$this
->set('package_type', $package_type
->getId());
$this
->recalculateWeight();
return $this;
}
/**
* {@inheritdoc}
*/
public function getShippingMethod() {
return $this
->get('shipping_method')->entity;
}
/**
* {@inheritdoc}
*/
public function setShippingMethod(ShippingMethodInterface $shipping_method) {
$this
->set('shipping_method', $shipping_method);
return $this;
}
/**
* {@inheritdoc}
*/
public function getShippingMethodId() {
return $this
->get('shipping_method')->target_id;
}
/**
* {@inheritdoc}
*/
public function setShippingMethodId($shipping_method_id) {
$this
->set('shipping_method', $shipping_method_id);
return $this;
}
/**
* {@inheritdoc}
*/
public function getShippingService() {
return $this
->get('shipping_service')->value;
}
/**
* {@inheritdoc}
*/
public function setShippingService($shipping_service) {
$this
->set('shipping_service', $shipping_service);
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 getTitle() {
return $this
->get('title')->value;
}
/**
* {@inheritdoc}
*/
public function setTitle($title) {
$this
->set('title', $title);
return $this;
}
/**
* {@inheritdoc}
*/
public function getItems() {
return $this
->get('items')
->getShipmentItems();
}
/**
* {@inheritdoc}
*/
public function setItems(array $shipment_items) {
$this
->set('items', $shipment_items);
$this
->recalculateWeight();
return $this;
}
/**
* {@inheritdoc}
*/
public function getTotalQuantity() {
$total_quantity = '0';
foreach ($this
->getItems() as $item) {
$total_quantity = Calculator::add($total_quantity, $item
->getQuantity());
}
return $total_quantity;
}
/**
* {@inheritdoc}
*/
public function hasItems() {
return !$this
->get('items')
->isEmpty();
}
/**
* {@inheritdoc}
*/
public function addItem(ShipmentItem $shipment_item) {
$this
->get('items')
->appendItem($shipment_item);
$this
->recalculateWeight();
return $this;
}
/**
* {@inheritdoc}
*/
public function removeItem(ShipmentItem $shipment_item) {
$this
->get('items')
->removeShipmentItem($shipment_item);
$this
->recalculateWeight();
return $this;
}
/**
* {@inheritdoc}
*/
public function getTotalDeclaredValue() {
$total_declared_value = NULL;
foreach ($this
->getItems() as $item) {
$declared_value = $item
->getDeclaredValue();
$total_declared_value = $total_declared_value ? $total_declared_value
->add($declared_value) : $declared_value;
}
return $total_declared_value;
}
/**
* {@inheritdoc}
*/
public function getWeight() {
if (!$this
->get('weight')
->isEmpty()) {
return $this
->get('weight')
->first()
->toMeasurement();
}
}
/**
* {@inheritdoc}
*/
public function setWeight(Weight $weight) {
$this
->set('weight', $weight);
return $this;
}
/**
* {@inheritdoc}
*/
public function getOriginalAmount() {
if (!$this
->get('original_amount')
->isEmpty()) {
return $this
->get('original_amount')
->first()
->toPrice();
}
}
/**
* {@inheritdoc}
*/
public function setOriginalAmount(Price $original_amount) {
$this
->set('original_amount', $original_amount);
return $this;
}
/**
* {@inheritdoc}
*/
public function getAmount() {
if (!$this
->get('amount')
->isEmpty()) {
return $this
->get('amount')
->first()
->toPrice();
}
}
/**
* {@inheritdoc}
*/
public function setAmount(Price $amount) {
$this
->set('amount', $amount);
return $this;
}
/**
* {@inheritdoc}
*/
public function getAdjustedAmount(array $adjustment_types = []) {
$amount = $this
->getAmount();
if (!$amount) {
return NULL;
}
foreach ($this
->getAdjustments($adjustment_types) as $adjustment) {
if (!$adjustment
->isIncluded()) {
$amount = $amount
->add($adjustment
->getAmount());
}
}
$rounder = \Drupal::service('commerce_price.rounder');
$amount = $rounder
->round($amount);
return $amount;
}
/**
* {@inheritdoc}
*/
public function getAdjustments(array $adjustment_types = []) {
/** @var \Drupal\commerce_order\Adjustment[] $adjustments */
$adjustments = $this
->get('adjustments')
->getAdjustments();
// Filter adjustments by type, if needed.
if ($adjustment_types) {
foreach ($adjustments as $index => $adjustment) {
if (!in_array($adjustment
->getType(), $adjustment_types)) {
unset($adjustments[$index]);
}
}
$adjustments = array_values($adjustments);
}
return $adjustments;
}
/**
* {@inheritdoc}
*/
public function setAdjustments(array $adjustments) {
$this
->set('adjustments', $adjustments);
return $this;
}
/**
* {@inheritdoc}
*/
public function addAdjustment(Adjustment $adjustment) {
$this
->get('adjustments')
->appendItem($adjustment);
return $this;
}
/**
* {@inheritdoc}
*/
public function removeAdjustment(Adjustment $adjustment) {
$this
->get('adjustments')
->removeAdjustment($adjustment);
return $this;
}
/**
* {@inheritdoc}
*/
public function clearAdjustments() {
$locked_callback = function ($adjustment) {
/** @var \Drupal\commerce_order\Adjustment $adjustment */
return $adjustment
->isLocked();
};
$adjustments = array_filter($this
->getAdjustments(), $locked_callback);
$this
->setAdjustments($adjustments);
return $this;
}
/**
* {@inheritdoc}
*/
public function getTrackingCode() {
return $this
->get('tracking_code')->value;
}
/**
* {@inheritdoc}
*/
public function setTrackingCode($tracking_code) {
$this
->set('tracking_code', $tracking_code);
return $this;
}
/**
* {@inheritdoc}
*/
public function getState() {
return $this
->get('state')
->first();
}
/**
* {@inheritdoc}
*/
public function getData($key, $default = NULL) {
$data = [];
if (!$this
->get('data')
->isEmpty()) {
$data = $this
->get('data')
->first()
->getValue();
}
return isset($data[$key]) ? $data[$key] : $default;
}
/**
* {@inheritdoc}
*/
public function setData($key, $value) {
$this
->get('data')
->__set($key, $value);
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 getShippedTime() {
return $this
->get('shipped')->value;
}
/**
* {@inheritdoc}
*/
public function setShippedTime($timestamp) {
$this
->set('shipped', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
$this
->prepareFields();
foreach ([
'order_id',
] as $field) {
if ($this
->get($field)
->isEmpty()) {
throw new EntityMalformedException(sprintf('Required shipment field "%s" is empty.', $field));
}
}
}
/**
* Ensures that the package_type and weight fields are populated.
*/
protected function prepareFields() {
if (empty($this
->getPackageType()) && !empty($this
->getShippingMethodId())) {
$shipping_method = $this
->getShippingMethod();
if ($shipping_method) {
$default_package_type = $shipping_method
->getPlugin()
->getDefaultPackageType();
$this
->set('package_type', $default_package_type
->getId());
}
}
$this
->recalculateWeight();
}
/**
* Recalculates the shipment's weight.
*/
protected function recalculateWeight() {
if (!$this
->hasItems()) {
// Can't calculate the weight if the items are still unavailable.
return;
}
/** @var \Drupal\physical\Weight $weight */
$weight = NULL;
foreach ($this
->getItems() as $shipment_item) {
$shipment_item_weight = $shipment_item
->getWeight();
$weight = $weight ? $weight
->add($shipment_item_weight) : $shipment_item_weight;
}
if ($package_type = $this
->getPackageType()) {
$package_type_weight = $package_type
->getWeight();
$weight = $weight
->add($package_type_weight);
}
$this
->setWeight($weight);
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
// The order backreference.
$fields['order_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Order'))
->setDescription(t('The parent order.'))
->setSetting('target_type', 'commerce_order')
->setRequired(TRUE)
->setReadOnly(TRUE);
$fields['package_type'] = BaseFieldDefinition::create('string')
->setLabel(t('Package type'))
->setDescription(t('The package type.'))
->setRequired(TRUE)
->setDefaultValue('')
->setSetting('max_length', 255)
->setDisplayConfigurable('view', TRUE);
$fields['shipping_method'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Shipping method'))
->setRequired(TRUE)
->setDescription(t('The shipping method'))
->setSetting('target_type', 'commerce_shipping_method')
->setDisplayOptions('form', [
'type' => 'commerce_shipping_rate',
'weight' => 0,
])
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'commerce_shipping_method',
'weight' => 0,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['shipping_service'] = BaseFieldDefinition::create('string')
->setLabel(t('Shipping service'))
->setRequired(TRUE)
->setDescription(t('The shipping service.'))
->setDefaultValue('')
->setSetting('max_length', 255);
$fields['shipping_profile'] = BaseFieldDefinition::create('entity_reference_revisions')
->setLabel(t('Shipping information'))
->setRequired(TRUE)
->setSetting('target_type', 'profile')
->setSetting('handler', 'default')
->setSetting('handler_settings', [
'target_bundles' => [
'customer' => 'customer',
],
])
->setDisplayOptions('form', [
'type' => 'commerce_shipping_profile',
'weight' => -10,
'settings' => [],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['title'] = BaseFieldDefinition::create('string')
->setLabel(t('Title'))
->setDescription(t('The shipment title.'))
->setRequired(TRUE)
->setSettings([
'default_value' => '',
'max_length' => 255,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -20,
])
->setDisplayConfigurable('view', TRUE)
->setDisplayConfigurable('form', TRUE);
$fields['items'] = BaseFieldDefinition::create('commerce_shipment_item')
->setLabel(t('Items'))
->setRequired(TRUE)
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
->setDisplayConfigurable('form', FALSE)
->setDisplayConfigurable('view', TRUE);
$fields['weight'] = BaseFieldDefinition::create('physical_measurement')
->setLabel(t('Weight'))
->setRequired(TRUE)
->setSetting('measurement_type', 'weight')
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['original_amount'] = BaseFieldDefinition::create('commerce_price')
->setLabel(t('Original amount'))
->setDescription(t('The original amount.'))
->setDisplayConfigurable('form', FALSE)
->setDisplayConfigurable('view', TRUE);
$fields['amount'] = BaseFieldDefinition::create('commerce_price')
->setLabel(t('Amount'))
->setDescription(t('The amount.'))
->setDisplayConfigurable('form', FALSE)
->setDisplayConfigurable('view', TRUE);
$fields['adjustments'] = BaseFieldDefinition::create('commerce_adjustment')
->setLabel(t('Adjustments'))
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
->setDisplayConfigurable('form', FALSE)
->setDisplayConfigurable('view', FALSE);
$fields['tracking_code'] = BaseFieldDefinition::create('string')
->setLabel(t('Tracking code'))
->setDescription(t('The shipment tracking code.'))
->setDefaultValue('')
->setSetting('max_length', 255)
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 50,
]);
$fields['state'] = BaseFieldDefinition::create('state')
->setLabel(t('State'))
->setDescription(t('The shipment state.'))
->setRequired(TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'state_transition_form',
'settings' => [
'require_confirmation' => TRUE,
'use_modal' => TRUE,
],
'weight' => 10,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setSetting('workflow_callback', [
'\\Drupal\\commerce_shipping\\Entity\\Shipment',
'getWorkflowId',
]);
$fields['data'] = BaseFieldDefinition::create('map')
->setLabel(t('Data'))
->setDescription(t('A serialized array of additional data.'));
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time when the shipment was created.'))
->setRequired(TRUE);
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time when the shipment was last updated.'))
->setRequired(TRUE);
$fields['shipped'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Shipped'))
->setDescription(t('The time when the shipment was shipped.'));
return $fields;
}
/**
* {@inheritdoc}
*/
public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
$shipment_type = ShipmentType::load($bundle);
if (!$shipment_type) {
throw new \RuntimeException(sprintf('Could not load the "%s" shipment type.', $bundle));
}
$fields = [];
$fields['shipping_profile'] = clone $base_field_definitions['shipping_profile'];
$fields['shipping_profile']
->setSetting('handler_settings', [
'target_bundles' => [
$shipment_type
->getProfileTypeId() => $shipment_type
->getProfileTypeId(),
],
]);
return $fields;
}
/**
* Gets the workflow ID for the state field.
*
* @param \Drupal\commerce_shipping\Entity\ShipmentInterface $shipment
* The shipment.
*
* @return string
* The workflow ID.
*/
public static function getWorkflowId(ShipmentInterface $shipment) {
if (!empty($shipping_method = $shipment
->get('shipping_method')->entity)) {
if (!empty($plugin = $shipping_method
->getPlugin())) {
return $plugin
->getWorkflowId();
}
}
return 'shipment_default';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
ContentEntityBase:: |
protected | property | Language code identifying the entity active language. | |
ContentEntityBase:: |
protected | property | Local cache for the default language code. | |
ContentEntityBase:: |
protected | property | The default langcode entity key. | |
ContentEntityBase:: |
protected | property | Whether the revision translation affected flag has been enforced. | |
ContentEntityBase:: |
protected | property | Holds untranslatable entity keys such as the ID, bundle, and revision ID. | |
ContentEntityBase:: |
protected | property | Local cache for field definitions. | |
ContentEntityBase:: |
protected | property | The array of fields, each being an instance of FieldItemListInterface. | |
ContentEntityBase:: |
protected static | property | Local cache for fields to skip from the checking for translation changes. | |
ContentEntityBase:: |
protected | property | Indicates whether this is the default revision. | |
ContentEntityBase:: |
protected | property | The language entity key. | |
ContentEntityBase:: |
protected | property | Local cache for the available language objects. | |
ContentEntityBase:: |
protected | property | The loaded revision ID before the new revision was set. | |
ContentEntityBase:: |
protected | property | Boolean indicating whether a new revision should be created on save. | |
ContentEntityBase:: |
protected | property | The revision translation affected entity key. | |
ContentEntityBase:: |
protected | property | Holds translatable entity keys such as the label. | |
ContentEntityBase:: |
protected | property | A flag indicating whether a translation object is being initialized. | |
ContentEntityBase:: |
protected | property | An array of entity translation metadata. | |
ContentEntityBase:: |
protected | property | Whether entity validation was performed. | |
ContentEntityBase:: |
protected | property | Whether entity validation is required before saving the entity. | |
ContentEntityBase:: |
protected | property | The plain data values of the contained fields. | |
ContentEntityBase:: |
public | function |
Checks data value access. Overrides EntityBase:: |
1 |
ContentEntityBase:: |
public | function |
Adds a new translation to the translatable object. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the bundle of the entity. Overrides EntityBase:: |
|
ContentEntityBase:: |
protected | function | Clear entity translation object cache to remove stale references. | |
ContentEntityBase:: |
public | function |
Creates a duplicate of the entity. Overrides EntityBase:: |
1 |
ContentEntityBase:: |
public | function |
Gets a field item list. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Gets the value of the given entity key, if defined. | 1 |
ContentEntityBase:: |
public | function |
Gets the definition of a contained field. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of all field item lists. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Returns an array of field names to skip in ::hasTranslationChanges. | 1 |
ContentEntityBase:: |
public | function | ||
ContentEntityBase:: |
protected | function | ||
ContentEntityBase:: |
public | function |
Gets the loaded Revision ID of the entity. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the revision identifier of the entity. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Gets a translated field. | |
ContentEntityBase:: |
public | function |
Gets a translation of the data. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the languages the data is translated to. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the translation status. Overrides TranslationStatusInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the translatable object referring to the original language. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Checks there is a translation for the given language code. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Determines if the current translation of the entity has unsaved changes. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the identifier. Overrides EntityBase:: |
|
ContentEntityBase:: |
protected | function | Instantiates a translation object for an existing translation. | |
ContentEntityBase:: |
public | function |
Checks if this entity is the default revision. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the translation is the default one. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks if untranslatable fields should affect only the default translation. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks if this entity is the latest revision. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether this is the latest revision affecting this translation. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Determines whether a new revision should be created on save. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the translation is new. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the current translation is affected by the current revision. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks if the revision translation affected flag value has been enforced. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the translation support status. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the label of the entity. Overrides EntityBase:: |
2 |
ContentEntityBase:: |
public | function |
Gets the language of the entity. Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function |
Reacts to changes to a field. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Acts on a created entity before hooks are invoked. Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function |
Acts on a saved entity before the insert or update hook is invoked. Overrides EntityBase:: |
5 |
ContentEntityBase:: |
public | function |
Acts on a revision before it gets saved. Overrides RevisionableInterface:: |
2 |
ContentEntityBase:: |
public | function |
Gets a list of entities referenced by this entity. Overrides EntityBase:: |
1 |
ContentEntityBase:: |
public | function |
Removes the translation identified by the given language code. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Sets a field value. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Populates the local cache for the default language code. | |
ContentEntityBase:: |
public | function |
Enforces an entity to be saved as a new revision. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Marks the current revision translation as affected. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Enforces the revision translation affected flag value. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Sets whether entity validation is required before saving the entity. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of all property values. Overrides EntityBase:: |
|
ContentEntityBase:: |
protected | function | Updates language for already instantiated fields. | |
ContentEntityBase:: |
public | function |
Updates the loaded Revision ID with the revision ID. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function | Updates the original values with the interim changes. | |
ContentEntityBase:: |
public | function |
Gets the entity UUID (Universally Unique Identifier). Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function |
Validates the currently set values. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the entity object was a default revision when it was saved. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function | Magic method: Implements a deep clone. | |
ContentEntityBase:: |
public | function |
Constructs an Entity object. Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function | Implements the magic method for getting object properties. | |
ContentEntityBase:: |
public | function | Implements the magic method for isset(). | |
ContentEntityBase:: |
public | function | Implements the magic method for setting object properties. | |
ContentEntityBase:: |
public | function |
Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function | Implements the magic method for unset(). | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | Aliased as: traitSleep | 1 |
DependencySerializationTrait:: |
public | function | 2 | |
EntityBase:: |
protected | property | Boolean indicating whether the entity should be forced to be new. | |
EntityBase:: |
protected | property | The entity type. | |
EntityBase:: |
protected | property | A typed data object wrapping this entity. | |
EntityBase:: |
public static | function |
Constructs a new entity object, without permanently saving it. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Deletes an entity permanently. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Enforces an entity to be new. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | Gets the entity manager. | |
EntityBase:: |
protected | function | Gets the entity type bundle info service. | |
EntityBase:: |
protected | function | Gets the entity type manager. | |
EntityBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the key that is used to store configuration dependencies. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the configuration dependency name. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets the configuration target identifier for the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets the entity type definition. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the ID of the type of the entity. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | The list cache tags to invalidate for this entity. | |
EntityBase:: |
public | function |
Gets the original ID. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets a typed data object for this entity object. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Indicates if a link template exists for a given key. Overrides EntityInterface:: |
|
EntityBase:: |
protected static | function | Invalidates an entity's cache tags upon delete. | 1 |
EntityBase:: |
protected | function | Invalidates an entity's cache tags upon save. | 1 |
EntityBase:: |
public | function |
Determines whether the entity is new. Overrides EntityInterface:: |
2 |
EntityBase:: |
protected | function | Gets the language manager. | |
EntityBase:: |
public | function |
Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets an array link templates. | 1 |
EntityBase:: |
public static | function |
Loads an entity. Overrides EntityInterface:: |
|
EntityBase:: |
public static | function |
Loads one or more entities. Overrides EntityInterface:: |
|
EntityBase:: |
public static | function |
Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface:: |
16 |
EntityBase:: |
public static | function |
Acts on loaded entities. Overrides EntityInterface:: |
2 |
EntityBase:: |
public static | function |
Changes the values of an entity before it is created. Overrides EntityInterface:: |
5 |
EntityBase:: |
public static | function |
Acts on entities before they are deleted and before hooks are invoked. Overrides EntityInterface:: |
4 |
EntityBase:: |
public | function |
Saves an entity permanently. Overrides EntityInterface:: |
3 |
EntityBase:: |
public | function |
Sets the original ID. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Generates the HTML for a link to this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets a list of URI relationships supported by this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the public URL for this entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets the UUID generator. | |
EntityChangedTrait:: |
public | function | Gets the timestamp of the last entity change for the current translation. | |
EntityChangedTrait:: |
public | function | Returns the timestamp of the last entity change across all translations. | |
EntityChangedTrait:: |
public | function | Sets the timestamp of the last entity change for the current translation. | |
EntityChangesDetectionTrait:: |
protected | function | Returns an array of field names to skip when checking for changes. Aliased as: traitGetFieldsToSkipFromTranslationChangesCheck | |
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
Shipment:: |
public | function |
Adds an adjustment. Overrides EntityAdjustableInterface:: |
|
Shipment:: |
public | function |
Adds a shipment item. Overrides ShipmentInterface:: |
|
Shipment:: |
public static | function |
Provides base field definitions for an entity type. Overrides ContentEntityBase:: |
|
Shipment:: |
public static | function |
Provides field definitions for a specific bundle. Overrides ContentEntityBase:: |
|
Shipment:: |
public | function |
Removes all adjustments that belong to the shipment. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Clears the shipment's rate, its shipping service & method. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the adjusted amount. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the adjustments. Overrides EntityAdjustableInterface:: |
|
Shipment:: |
public | function |
Gets the amount. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the shipment creation timestamp. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets a shipment data value with the given key. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the shipment items. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the parent order. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the parent order ID. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the original amount. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the package type. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the shipment shipped timestamp. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the shipping method. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the shipping method ID. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the shipping profile. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the shipping service. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the shipment state. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the shipment title. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the total declared value. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the total quantity. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the shipment tracking code. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Gets the shipment weight. Overrides ShipmentInterface:: |
|
Shipment:: |
public static | function | Gets the workflow ID for the state field. | |
Shipment:: |
public | function |
Gets whether the shipment has items. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Populates the shipment from the given proposed shipment. Overrides ShipmentInterface:: |
|
Shipment:: |
protected | function | Ensures that the package_type and weight fields are populated. | |
Shipment:: |
public | function |
Acts on an entity before the presave hook is invoked. Overrides ContentEntityBase:: |
|
Shipment:: |
protected | function | Recalculates the shipment's weight. | |
Shipment:: |
public | function |
Removes an adjustment. Overrides EntityAdjustableInterface:: |
|
Shipment:: |
public | function |
Removes a shipment item. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the adjustments. Overrides EntityAdjustableInterface:: |
|
Shipment:: |
public | function |
Sets the amount. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the shipment creation timestamp. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets a shipment data value with the given key. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the shipment items. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the original amount. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the package type. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the shipment shipped timestamp. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the shipping method. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the shipping method ID. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the shipping profile. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the shipping service. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the shipment title. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the shipment tracking code. Overrides ShipmentInterface:: |
|
Shipment:: |
public | function |
Sets the shipment weight. Overrides ShipmentInterface:: |
|
Shipment:: |
protected | function |
Gets an array of placeholders for this entity. Overrides EntityBase:: |
|
SynchronizableEntityTrait:: |
protected | property | Whether this entity is being created, updated or deleted through a synchronization process. | |
SynchronizableEntityTrait:: |
public | function | ||
SynchronizableEntityTrait:: |
public | function | ||
TranslationStatusInterface:: |
constant | Status code identifying a newly created translation. | ||
TranslationStatusInterface:: |
constant | Status code identifying an existing translation. | ||
TranslationStatusInterface:: |
constant | Status code identifying a removed translation. |