You are here

public function OrderCustomerRole::evaluate in Commerce Core 8.2

Evaluates the condition.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity.

Return value

bool TRUE if the condition has been met, FALSE otherwise.

Overrides ConditionInterface::evaluate

File

modules/order/src/Plugin/Commerce/Condition/OrderCustomerRole.php, line 61

Class

OrderCustomerRole
Provides the customer role condition for orders.

Namespace

Drupal\commerce_order\Plugin\Commerce\Condition

Code

public function evaluate(EntityInterface $entity) {
  $this
    ->assertEntity($entity);

  /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
  $order = $entity;
  $customer = $order
    ->getCustomer();
  return (bool) array_intersect($this->configuration['roles'], $customer
    ->getRoles());
}