class ProductDefaultVariationEvent in Commerce Core 8.2
Hierarchy
- class \Drupal\commerce\EventBase extends \Drupal\Component\EventDispatcher\Event
- class \Drupal\commerce_product\Event\ProductDefaultVariationEvent
Expanded class hierarchy of ProductDefaultVariationEvent
2 files declare their use of ProductDefaultVariationEvent
- DefaultVariationSubscriber.php in modules/
product/ tests/ modules/ commerce_product_test/ src/ EventSubscriber/ DefaultVariationSubscriber.php - Product.php in modules/
product/ src/ Entity/ Product.php
File
- modules/
product/ src/ Event/ ProductDefaultVariationEvent.php, line 9
Namespace
Drupal\commerce_product\EventView source
class ProductDefaultVariationEvent extends EventBase {
/**
* The default product variation or null.
*
* @var \Drupal\commerce_product\Entity\ProductVariationInterface|null
*/
protected $defaultVariation;
/**
* The product.
*
* @var \Drupal\commerce_product\Entity\ProductInterface
*/
protected $product;
/**
* Constructs a new ProductDefaultVariationEvent object.
*
* @param \Drupal\commerce_product\Entity\ProductVariationInterface|null $default_variation
* The product variation or null.
* @param \Drupal\commerce_product\Entity\ProductInterface $product
* The product.
*/
public function __construct($default_variation, ProductInterface $product) {
$this->defaultVariation = $default_variation;
$this->product = $product;
}
/**
* Gets the product.
*
* @return \Drupal\commerce_product\Entity\ProductInterface
* The product.
*/
public function getProduct() {
return $this->product;
}
/**
* Set the default product variation.
*
* @param \Drupal\commerce_product\Entity\ProductVariationInterface $default_variation
* The variation.
*/
public function setDefaultVariation(ProductVariationInterface $default_variation) {
$this->defaultVariation = $default_variation;
}
/**
* Gets the default product variation.
*
* @return \Drupal\commerce_product\Entity\ProductVariationInterface|null
* The default variation, or NULL if none found.
*/
public function getDefaultVariation() {
return $this->defaultVariation;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ProductDefaultVariationEvent:: |
protected | property | The default product variation or null. | |
ProductDefaultVariationEvent:: |
protected | property | The product. | |
ProductDefaultVariationEvent:: |
public | function | Gets the default product variation. | |
ProductDefaultVariationEvent:: |
public | function | Gets the product. | |
ProductDefaultVariationEvent:: |
public | function | Set the default product variation. | |
ProductDefaultVariationEvent:: |
public | function | Constructs a new ProductDefaultVariationEvent object. |