commerce_shipping-8.x-2.0-rc2/tests/modules/commerce_shipping_test/src/Plugin/Commerce/ShippingMethod/ExceptionThrower.php

tests/modules/commerce_shipping_test/src/Plugin/Commerce/ShippingMethod/ExceptionThrower.php
<?php

namespace Drupal\commerce_shipping_test\Plugin\Commerce\ShippingMethod;

use Drupal\commerce_shipping\Attribute\CommerceShippingMethod;
use Drupal\commerce_shipping\Entity\ShipmentInterface;
use Drupal\commerce_shipping\Plugin\Commerce\ShippingMethod\ShippingMethodBase;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Provides a shipping method that throws an exception when calculating rates.
 */
#[CommerceShippingMethod(
  id: 'exception_thrower',
  label: new TranslatableMarkup('Exception Thrower'),
)]
class ExceptionThrower extends ShippingMethodBase {

  /**
   * {@inheritdoc}
   */
  public function calculateRates(ShipmentInterface $shipment) {
    throw new \Exception('Simulate a shipping plugin that throws an exception when calculating rates.');
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc