interface BundleItemInterface in Commerce Product Bundle 8
Provides an interface for defining product bundle item entities.
Hierarchy
- interface \Drupal\Core\Entity\EntityChangedInterface; interface \Drupal\user\EntityOwnerInterface
- interface \Drupal\commerce_product_bundle\Entity\BundleItemInterface
Expanded class hierarchy of BundleItemInterface
All classes that implement BundleItemInterface
2 files declare their use of BundleItemInterface
- MinQtyLessThanOrEqualMaxQtyConstraintValidatorTest.php in tests/
src/ Unit/ Plugin/ Validation/ Constraint/ MinQtyLessThanOrEqualMaxQtyConstraintValidatorTest.php - ProductBundleItemsWidget.php in src/
Plugin/ Field/ FieldWidget/ ProductBundleItemsWidget.php
File
- src/
Entity/ BundleItemInterface.php, line 16
Namespace
Drupal\commerce_product_bundle\EntityView source
interface BundleItemInterface extends EntityChangedInterface, EntityOwnerInterface {
/**
* Gets the product bundle item title.
*
* @return string
* Title of the product bundle item.
*/
public function getTitle();
/**
* Sets the product bundle item title.
*
* @param string $title
* The product bundle item title.
*
* @return \Drupal\commerce_product_bundle\Entity\BundleItemInterface
* The called product bundle item entity.
*/
public function setTitle($title);
/**
* Set whether the product bundle item is required or not.
*
* @param bool $required
* Set TRUE if required, FALSE if optional.
*
* @return \Drupal\commerce_product_bundle\Entity\BundleItemInterface
* The called product bundle item entity.
*/
public function setRequired($required);
/**
* Whether the product bundle item is required or not.
*
* @return bool
* TRUE if required, FALSE if optional.
*/
public function isRequired();
/**
* Gets the product bundle item creation timestamp.
*
* @return int
* Creation timestamp of the product bundle item.
*/
public function getCreatedTime();
/**
* Sets the product bundle item creation timestamp.
*
* @param int $timestamp
* The product bundle item creation timestamp.
*
* @return \Drupal\commerce_product_bundle\Entity\BundleItemInterface
* The called product bundle item entity.
*/
public function setCreatedTime($timestamp);
/**
* Gets the parent bundle entity.
*
* @return \Drupal\commerce_product_bundle\Entity\BundleInterface
* The product bundle entity, or null.
*/
public function getBundle();
/**
* Gets the parent product bundle ID.
*
* @return int
* The product bundle ID, or null.
*/
public function getBundleId();
/**
* Gets the bundle item quantity.
*
* @return float
* The bundle item quantity
*/
public function getQuantity();
/**
* Sets the quantity for the bundle item.
*
* @param float $quantity
* The bundle item quantity.
*
* @return \Drupal\commerce_product_bundle\Entity\BundleItemInterface
* The called product bundle item entity.
*/
public function setQuantity($quantity);
/**
* Sets the minimum quantity of the product variations.
*
* @param float $minimum_quantity
* The minimum quantity.
*
* @return \Drupal\commerce_product_bundle\Entity\BundleItemInterface
* The called product bundle item entity.
*/
public function setMinimumQuantity($minimum_quantity);
/**
* Gets the minimum quantity of the product variations.
*
* @return float
* The minimum quantity.
*/
public function getMinimumQuantity();
/**
* Sets the maximum quantity of the product variations.
*
* @param float $maximum_quantity
* The maximum quantity.
*
* @return \Drupal\commerce_product_bundle\Entity\BundleItemInterface
* The called product bundle item entity.
*/
public function setMaximumQuantity($maximum_quantity);
/**
* Gets the maximum quantity of the product variations.
*
* @return float
* The maximum quantity.
*/
public function getMaximumQuantity();
/**
* Gets whether the bundle item has a product set or not.
*
* @return bool
* TRUE if the bundle item contains a product reference. FALSE otherwise.
*/
public function hasProduct();
/**
* Get the referenced product.
*
* @return null|\Drupal\commerce_product\Entity\ProductInterface
* The referenced commerce product or null
* if no product is referenced.
*/
public function getProduct();
/**
* Gets the bundle item's product id.
*
* @return string|int
* The bundle item's product id.
*/
public function getProductId();
/**
* Set the referenced product.
*
* If a new product is referenced, the variations references will be
* resetted.
*
* @param \Drupal\commerce_product\Entity\ProductInterface $product
* The product.
*
* @return $this
*/
public function setProduct(ProductInterface $product);
/**
* Sets the variations.
*
* If the bundle item doesn't hold a product reference yet, the product of the
* first variation will be set as the bundle items product.
*
* @param \Drupal\commerce_product\Entity\ProductVariationInterface[] $variations
* The variations.
*
* @throws \InvalidArgumentException
* In case the variations don't belong to the same product or if applicable to
* the already referenced product.
*
* @return \Drupal\commerce_product_bundle\Entity\BundleItemInterface
* The called product bundle item entity.
*/
public function setVariations(array $variations);
/**
* Gets whether the bundle item has restricted variations.
*
* @return bool
* TRUE if the bundle item has restricted available variations, FALSE otherwise.
*/
public function hasVariations();
/**
* Gets the product variations limited by the bundle item or enabled on the product.
*
* This method returns the variations, if any, specified (limited) by
* the bundle item, or fall back to all enabled variations of the referenced product.
*
* @return \Drupal\commerce_product\Entity\ProductVariationInterface[]
* The product variations.
*/
public function getVariations();
/**
* Gets the variation IDs.
*
* @return int[]
* The variation IDs.
*/
public function getVariationIds();
/**
* Get the default variation.
*
* @return \Drupal\commerce_product\Entity\ProductVariationInterface
* The default product variation.
*/
public function getDefaultVariation();
/**
* Adds a variation.
*
* If the bundle item does not yet hold a product reference, nothing happens.
* So if you unsure you should propably check for existence of the product
* reference.
*
* If the bundle item has a product reference, but doesn't restrict
* the variations, nothing will happen. You can check for this
* with hasVariations().
*
* @code
* if($bundleItem->hasProduct() && $bundleItem->hasVariations()){
* $bundleItem->addVariation($variation)
* } else {
* $bundleItem->setVariations([$variation]);
* }
* @endcode
*
* @param \Drupal\commerce_product\Entity\ProductVariationInterface $variation
* The variation.
*
* @throws \InvalidArgumentException
* In case the variation don't belong to the referenced product.
*
* @return $this
*/
public function addVariation(ProductVariationInterface $variation);
/**
* Removes a variation.
*
* @param \Drupal\commerce_product\Entity\ProductVariationInterface $variation
* The variation.
*
* @return $this
*/
public function removeVariation(ProductVariationInterface $variation);
/**
* Gets the currently selected variation, or the default variation.
*
* @return \Drupal\commerce_product\Entity\ProductVariationInterface
* The variation.
*/
public function getCurrentVariation();
/**
* Gets the currently selected variation, or the default variation.
*
* @param \Drupal\commerce_product\Entity\ProductVariationInterface $variation
* The variation.
*
* @throws \InvalidArgumentException
* In case the variation passed as argument is not referenced by the bundle
* item.
*
* @return $this
*/
public function setCurrentVariation(ProductVariationInterface $variation);
/**
* Sets the price of one unit of the referenced
* product variations.
*
* @param \Drupal\commerce_price\Price $unit_price
* The unit price.
*
* @return \Drupal\commerce_product_bundle\Entity\BundleItemInterface
* The called product bundle item entity.
*/
public function setUnitPrice(Price $unit_price);
/**
* Gets the price of one unit of the referenced
* product variations.
*
* @return \Drupal\commerce_price\Price|null
* The unit price or NULL.
*/
public function getUnitPrice();
/**
* Check whether the bundleItem has an own unit price.
*
* @return bool
* True it the bundle item has an own unit price set,
* false if not.
*/
public function hasUnitPrice();
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AccessibleInterface:: |
public | function | Checks data value access. | 9 |
BundleItemInterface:: |
public | function | Adds a variation. | 1 |
BundleItemInterface:: |
public | function | Gets the parent bundle entity. | 1 |
BundleItemInterface:: |
public | function | Gets the parent product bundle ID. | 1 |
BundleItemInterface:: |
public | function | Gets the product bundle item creation timestamp. | 1 |
BundleItemInterface:: |
public | function | Gets the currently selected variation, or the default variation. | 1 |
BundleItemInterface:: |
public | function | Get the default variation. | 1 |
BundleItemInterface:: |
public | function | Gets the maximum quantity of the product variations. | 1 |
BundleItemInterface:: |
public | function | Gets the minimum quantity of the product variations. | 1 |
BundleItemInterface:: |
public | function | Get the referenced product. | 1 |
BundleItemInterface:: |
public | function | Gets the bundle item's product id. | 1 |
BundleItemInterface:: |
public | function | Gets the bundle item quantity. | 1 |
BundleItemInterface:: |
public | function | Gets the product bundle item title. | 1 |
BundleItemInterface:: |
public | function | Gets the price of one unit of the referenced product variations. | 1 |
BundleItemInterface:: |
public | function | Gets the variation IDs. | 1 |
BundleItemInterface:: |
public | function | Gets the product variations limited by the bundle item or enabled on the product. | 1 |
BundleItemInterface:: |
public | function | Gets whether the bundle item has a product set or not. | 1 |
BundleItemInterface:: |
public | function | Check whether the bundleItem has an own unit price. | 1 |
BundleItemInterface:: |
public | function | Gets whether the bundle item has restricted variations. | 1 |
BundleItemInterface:: |
public | function | Whether the product bundle item is required or not. | 1 |
BundleItemInterface:: |
public | function | Removes a variation. | 1 |
BundleItemInterface:: |
public | function | Sets the product bundle item creation timestamp. | 1 |
BundleItemInterface:: |
public | function | Gets the currently selected variation, or the default variation. | 1 |
BundleItemInterface:: |
public | function | Sets the maximum quantity of the product variations. | 1 |
BundleItemInterface:: |
public | function | Sets the minimum quantity of the product variations. | 1 |
BundleItemInterface:: |
public | function | Set the referenced product. | 1 |
BundleItemInterface:: |
public | function | Sets the quantity for the bundle item. | 1 |
BundleItemInterface:: |
public | function | Set whether the product bundle item is required or not. | 1 |
BundleItemInterface:: |
public | function | Sets the product bundle item title. | 1 |
BundleItemInterface:: |
public | function | Sets the price of one unit of the referenced product variations. | 1 |
BundleItemInterface:: |
public | function | Sets the variations. | 1 |
CacheableDependencyInterface:: |
public | function | The cache contexts associated with this object. | 34 |
CacheableDependencyInterface:: |
public | function | The maximum age for which this object may be cached. | 34 |
CacheableDependencyInterface:: |
public | function | The cache tags associated with this object. | 27 |
EntityChangedInterface:: |
public | function | Gets the timestamp of the last entity change for the current translation. | |
EntityChangedInterface:: |
public | function | Gets the timestamp of the last entity change across all translations. | |
EntityChangedInterface:: |
public | function | Sets the timestamp of the last entity change for the current translation. | |
EntityInterface:: |
public | function | Gets the bundle of the entity. | 2 |
EntityInterface:: |
public static | function | Constructs a new entity object, without permanently saving it. | 2 |
EntityInterface:: |
public | function | Creates a duplicate of the entity. | 2 |
EntityInterface:: |
public | function | Deletes an entity permanently. | 2 |
EntityInterface:: |
public | function | Enforces an entity to be new. | 2 |
EntityInterface:: |
public | function | Returns the cache tags that should be used to invalidate caches. | 2 |
EntityInterface:: |
public | function | Gets the key that is used to store configuration dependencies. | 2 |
EntityInterface:: |
public | function | Gets the configuration dependency name. | 2 |
EntityInterface:: |
public | function | Gets the configuration target identifier for the entity. | 2 |
EntityInterface:: |
public | function | Gets the entity type definition. | 2 |
EntityInterface:: |
public | function | Gets the ID of the type of the entity. | 2 |
EntityInterface:: |
public | function | Gets the original ID. | 2 |
EntityInterface:: |
public | function | Gets a typed data object for this entity object. | 2 |
EntityInterface:: |
public | function | Indicates if a link template exists for a given key. | 2 |
EntityInterface:: |
public | function | Gets the identifier. | 2 |
EntityInterface:: |
public | function | Determines whether the entity is new. | 2 |
EntityInterface:: |
public | function | Gets the label of the entity. | 2 |
EntityInterface:: |
public | function | Gets the language of the entity. | 2 |
EntityInterface:: |
public | function | Deprecated way of generating a link to the entity. See toLink(). | 2 |
EntityInterface:: |
public static | function | Loads an entity. | 2 |
EntityInterface:: |
public static | function | Loads one or more entities. | 2 |
EntityInterface:: |
public | function | Acts on a created entity before hooks are invoked. | 2 |
EntityInterface:: |
public static | function | Acts on deleted entities before the delete hook is invoked. | 2 |
EntityInterface:: |
public static | function | Acts on loaded entities. | 3 |
EntityInterface:: |
public | function | Acts on a saved entity before the insert or update hook is invoked. | 2 |
EntityInterface:: |
public static | function | Changes the values of an entity before it is created. | 2 |
EntityInterface:: |
public static | function | Acts on entities before they are deleted and before hooks are invoked. | 2 |
EntityInterface:: |
public | function | Acts on an entity before the presave hook is invoked. | 2 |
EntityInterface:: |
public | function | Gets a list of entities referenced by this entity. | 2 |
EntityInterface:: |
public | function | Saves an entity permanently. | 2 |
EntityInterface:: |
public | function | Sets the original ID. | 2 |
EntityInterface:: |
public | function | Gets an array of all property values. | 3 |
EntityInterface:: |
public | function | Generates the HTML for a link to this entity. | 2 |
EntityInterface:: |
public | function | Gets the URL object for the entity. | 2 |
EntityInterface:: |
public | function | Gets a list of URI relationships supported by this entity. | 2 |
EntityInterface:: |
public | function | Gets the public URL for this entity. | 2 |
EntityInterface:: |
public | function | Gets the URL object for the entity. | 2 |
EntityInterface:: |
public | function | Gets the entity UUID (Universally Unique Identifier). | 2 |
EntityOwnerInterface:: |
public | function | Returns the entity owner's user entity. | 1 |
EntityOwnerInterface:: |
public | function | Returns the entity owner's user ID. | 1 |
EntityOwnerInterface:: |
public | function | Sets the entity owner's user entity. | 1 |
EntityOwnerInterface:: |
public | function | Sets the entity owner's user ID. | 1 |
RefinableCacheableDependencyInterface:: |
public | function | Adds a dependency on an object: merges its cacheability metadata. | 1 |
RefinableCacheableDependencyInterface:: |
public | function | Adds cache contexts. | 1 |
RefinableCacheableDependencyInterface:: |
public | function | Adds cache tags. | 1 |
RefinableCacheableDependencyInterface:: |
public | function | Merges the maximum age (in seconds) with the existing maximum age. | 1 |