EventException.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Sync\Exception;
  6. use Magento\Framework\Exception\LocalizedException;
  7. /**
  8. * Temando General Event Exception
  9. *
  10. * The event cannot and should not get handled.
  11. *
  12. * @package Temando\Shipping\Sync
  13. * @author Christoph Aßmann <christoph.assmann@netresearch.de>
  14. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  15. * @link http://www.temando.com/
  16. */
  17. class EventException extends LocalizedException
  18. {
  19. /**
  20. * @param string $entityType
  21. * @param \Exception|null $previous
  22. *
  23. * @return static
  24. */
  25. public static function unknownEntityType($entityType, \Exception $previous = null)
  26. {
  27. $phrase = __("Entity type '%1' cannot be processed.", $entityType);
  28. return new static($phrase, $previous);
  29. }
  30. /**
  31. * @param string $entityType
  32. * @param string $eventType
  33. *
  34. * @return static
  35. */
  36. public static function unknownOperation($entityType, $eventType)
  37. {
  38. $phrase = __("The '%1' operation is not supported for '%2' entities.", $eventType, $entityType);
  39. return new static($phrase);
  40. }
  41. /**
  42. * @param string $entityType
  43. * @param string $eventType
  44. * @param string $entityId
  45. * @param string $reason
  46. *
  47. * @return static
  48. */
  49. public static function operationSkipped($entityType, $eventType, $entityId, $reason = '')
  50. {
  51. $phrase = __(
  52. "The '%1' operation was skipped for %2 %3%4",
  53. $eventType,
  54. $entityType,
  55. $entityId,
  56. $reason ? ": $reason" : '.'
  57. );
  58. return new static($phrase);
  59. }
  60. }