class FilterConditionsEventSubscriber in Commerce Core 8.2
Same name in this branch
- 8.2 modules/payment/src/EventSubscriber/FilterConditionsEventSubscriber.php \Drupal\commerce_payment\EventSubscriber\FilterConditionsEventSubscriber
- 8.2 modules/promotion/src/EventSubscriber/FilterConditionsEventSubscriber.php \Drupal\commerce_promotion\EventSubscriber\FilterConditionsEventSubscriber
Hierarchy
- class \Drupal\commerce_promotion\EventSubscriber\FilterConditionsEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of FilterConditionsEventSubscriber
1 string reference to 'FilterConditionsEventSubscriber'
- commerce_promotion.services.yml in modules/
promotion/ commerce_promotion.services.yml - modules/promotion/commerce_promotion.services.yml
1 service uses FilterConditionsEventSubscriber
File
- modules/
promotion/ src/ EventSubscriber/ FilterConditionsEventSubscriber.php, line 8
Namespace
Drupal\commerce_promotion\EventSubscriberView source
class FilterConditionsEventSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = [
'commerce.filter_conditions' => 'onFilterConditions',
];
return $events;
}
/**
* Removes unneeded conditions.
*
* Promotions have store and order_types base fields that are used for
* filtering, so there's no need to have conditions targeting the same data.
*
* @param \Drupal\commerce\Event\FilterConditionsEvent $event
* The event.
*/
public function onFilterConditions(FilterConditionsEvent $event) {
if ($event
->getParentEntityTypeId() == 'commerce_promotion') {
$definitions = $event
->getDefinitions();
unset($definitions['order_store']);
unset($definitions['order_type']);
$event
->setDefinitions($definitions);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FilterConditionsEventSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
FilterConditionsEventSubscriber:: |
public | function | Removes unneeded conditions. |