class CartEventSubscriber in Commerce Cart Flyout 8
Replaces the original CartEventSubscriber from commerce_cart module.
This prevents `_cart_api` routes from triggering messages.
Hierarchy
- class \Drupal\commerce_cart\EventSubscriber\CartEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface uses StringTranslationTrait
- class \Drupal\commerce_cart_flyout\EventSubscriber\CartEventSubscriber
Expanded class hierarchy of CartEventSubscriber
1 file declares its use of CartEventSubscriber
File
- src/
EventSubscriber/ CartEventSubscriber.php, line 17
Namespace
Drupal\commerce_cart_flyout\EventSubscriberView source
class CartEventSubscriber extends CommerceCartEventSubscriber {
/**
* The route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* Constructs a new CartEventSubscriber object.
*
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation.
*/
public function __construct(MessengerInterface $messenger, TranslationInterface $string_translation, RouteMatchInterface $route_match) {
parent::__construct($messenger, $string_translation);
$this->routeMatch = $route_match;
}
/**
* {@inheritdoc}
*/
public function displayAddToCartMessage(CartEntityAddEvent $event) {
if (!$this->routeMatch
->getRouteObject()
->hasRequirement('_cart_api')) {
parent::displayAddToCartMessage($event);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CartEventSubscriber:: |
protected | property | The messenger. | |
CartEventSubscriber:: |
protected | property | The route match. | |
CartEventSubscriber:: |
public | function |
Displays an add to cart message. Overrides CartEventSubscriber:: |
|
CartEventSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
CartEventSubscriber:: |
public | function |
Constructs a new CartEventSubscriber object. Overrides CartEventSubscriber:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |