OrderEmail.php in Commerce Core 8.2
File
modules/order/src/Plugin/Commerce/Condition/OrderEmail.php
View source
<?php
namespace Drupal\commerce_order\Plugin\Commerce\Condition;
use Drupal\commerce\Plugin\Commerce\Condition\ConditionBase;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
class OrderEmail extends ConditionBase {
public function defaultConfiguration() {
return [
'mail' => NULL,
] + parent::defaultConfiguration();
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['mail'] = [
'#type' => 'email',
'#title' => $this
->t('Email'),
'#default_value' => $this->configuration['mail'],
'#required' => TRUE,
];
return $form;
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
$values = $form_state
->getValue($form['#parents']);
$this->configuration['mail'] = $values['mail'];
}
public function evaluate(EntityInterface $entity) {
$this
->assertEntity($entity);
$order = $entity;
return strcasecmp($this->configuration['mail'], $order
->getEmail()) === 0;
}
}
Classes
Name |
Description |
OrderEmail |
Provides the Email address condition for orders. |