You are here

class FedExEventSubscriber in Commerce FedEx 8

Same name in this branch
  1. 8 modules/dry_ice/src/EventSubscriber/FedExEventSubscriber.php \Drupal\commerce_fedex_dry_ice\EventSubscriber\FedExEventSubscriber
  2. 8 modules/dangerous/src/EventSubscriber/FedExEventSubscriber.php \Drupal\commerce_fedex_dangerous\EventSubscriber\FedExEventSubscriber

Provides a FedEx event subscriber.

@package Drupal\commerce_fedex_dry_ice\EventSubscriber

Hierarchy

Expanded class hierarchy of FedExEventSubscriber

1 string reference to 'FedExEventSubscriber'
commerce_fedex_dry_ice.services.yml in modules/dry_ice/commerce_fedex_dry_ice.services.yml
modules/dry_ice/commerce_fedex_dry_ice.services.yml
1 service uses FedExEventSubscriber
commerce_fedex_dry_ice.fedex_event_subscriber in modules/dry_ice/commerce_fedex_dry_ice.services.yml
\Drupal\commerce_fedex_dry_ice\EventSubscriber\FedExEventSubscriber

File

modules/dry_ice/src/EventSubscriber/FedExEventSubscriber.php, line 16

Namespace

Drupal\commerce_fedex_dry_ice\EventSubscriber
View source
class FedExEventSubscriber implements EventSubscriberInterface {
  use StringTranslationTrait;

  /**
   * The package type manager.
   *
   * @var \Drupal\commerce_shipping\PackageTypeManagerInterface
   */
  protected $packageTypeManager;

  /**
   * Constructs a new ShippingMethodBase object.
   *
   * @param \Drupal\commerce_shipping\PackageTypeManagerInterface $package_type_manager
   *   The package type manager.
   */
  public function __construct(PackageTypeManagerInterface $package_type_manager) {
    $this->packageTypeManager = $package_type_manager;
  }

  /**
   * Alter the rate request event.
   *
   * @param \Drupal\commerce_fedex\Event\RateRequestEvent $event
   *   The rate request event.
   */
  public function onBeforeRateRequest(RateRequestEvent $event) {
    $rateRequest = $event
      ->getRateRequest();
    $shipment = $event
      ->getShipment();

    // @todo Alter the rate request.
  }

  /**
   * Function getSubscribedEvents.
   *
   * @return array
   *   The subscribed events
   */
  public static function getSubscribedEvents() {
    $events = [];
    $events[CommerceFedExEvents::BEFORE_RATE_REQUEST][] = [
      'onBeforeRateRequest',
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FedExEventSubscriber::$packageTypeManager protected property The package type manager.
FedExEventSubscriber::getSubscribedEvents public static function Function getSubscribedEvents.
FedExEventSubscriber::onBeforeRateRequest public function Alter the rate request event.
FedExEventSubscriber::__construct public function Constructs a new ShippingMethodBase object.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.