You are here

class ProductDefaultVariationEvent in Commerce Core 8.2

Hierarchy

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\Event
View 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

Namesort descending Modifiers Type Description Overrides
ProductDefaultVariationEvent::$defaultVariation protected property The default product variation or null.
ProductDefaultVariationEvent::$product protected property The product.
ProductDefaultVariationEvent::getDefaultVariation public function Gets the default product variation.
ProductDefaultVariationEvent::getProduct public function Gets the product.
ProductDefaultVariationEvent::setDefaultVariation public function Set the default product variation.
ProductDefaultVariationEvent::__construct public function Constructs a new ProductDefaultVariationEvent object.