You are here

public function Promotion::setCompatibility in Commerce Core 8.2

Sets the promotion compatibility.

Parameters

string $compatibility: The compatibility.

Return value

$this

Overrides PromotionInterface::setCompatibility

File

modules/promotion/src/Entity/Promotion.php, line 464

Class

Promotion
Defines the promotion entity class.

Namespace

Drupal\commerce_promotion\Entity

Code

public function setCompatibility($compatibility) {
  if (!in_array($compatibility, [
    self::COMPATIBLE_NONE,
    self::COMPATIBLE_ANY,
  ])) {
    throw new \InvalidArgumentException('Invalid compatibility type');
  }
  $this
    ->get('compatibility')->value = $compatibility;
  return $this;
}