| @@ 12-37 (lines=26) @@ | ||
| 9 | * @package Event Espresso |
|
| 10 | * @author Brent Christensen |
|
| 11 | */ |
|
| 12 | class UnexpectedEntityException extends \UnexpectedValueException |
|
| 13 | { |
|
| 14 | ||
| 15 | /** |
|
| 16 | * UnexpectedEntityException constructor |
|
| 17 | * |
|
| 18 | * @param mixed $entity the actual object or variable that was received |
|
| 19 | * @param string $expected_class classname of the entity we wanted |
|
| 20 | * @param string $message |
|
| 21 | * @param int $code |
|
| 22 | * @param \Exception $previous |
|
| 23 | */ |
|
| 24 | public function __construct($entity, $expected_class, $message = '', $code = 0, \Exception $previous = null) |
|
| 25 | { |
|
| 26 | if (empty($message)) { |
|
| 27 | $message = sprintf( |
|
| 28 | __( |
|
| 29 | 'The retrieved entity is an instance of "%1$s", but an instance of "%2$s" was expected.', |
|
| 30 | 'event_espresso' |
|
| 31 | ), |
|
| 32 | is_object($entity) ? get_class($entity) : gettype($entity), |
|
| 33 | $expected_class |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | parent::__construct($message, $code, $previous); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| @@ 15-50 (lines=36) @@ | ||
| 12 | * @author Brent Christensen |
|
| 13 | * @since 4.9.1 |
|
| 14 | */ |
|
| 15 | class InvalidCommandBusMiddlewareException extends InvalidDataTypeException |
|
| 16 | { |
|
| 17 | ||
| 18 | ||
| 19 | /** |
|
| 20 | * @access public |
|
| 21 | * @param mixed $command_bus_middleware_object |
|
| 22 | * @param string $message |
|
| 23 | * @param int $code |
|
| 24 | * @param \Exception $previous |
|
| 25 | */ |
|
| 26 | public function __construct($command_bus_middleware_object, $message = '', $code = 0, \Exception $previous = null) |
|
| 27 | { |
|
| 28 | $command_bus_middleware = is_object($command_bus_middleware_object) |
|
| 29 | ? get_class($command_bus_middleware_object) |
|
| 30 | : gettype($command_bus_middleware_object); |
|
| 31 | ||
| 32 | if (empty($message)) { |
|
| 33 | $message = sprintf( |
|
| 34 | __( |
|
| 35 | 'The supplied Command Bus Middleware "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', |
|
| 36 | 'event_espresso' |
|
| 37 | ), |
|
| 38 | $command_bus_middleware |
|
| 39 | ); |
|
| 40 | } |
|
| 41 | parent::__construct( |
|
| 42 | '$command_bus_middleware', |
|
| 43 | $command_bus_middleware, |
|
| 44 | 'CommandBusMiddlewareInterface', |
|
| 45 | $message, |
|
| 46 | $code, |
|
| 47 | $previous |
|
| 48 | ); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| @@ 15-47 (lines=33) @@ | ||
| 12 | * @author Brent Christensen |
|
| 13 | * @since 4.9.59.p |
|
| 14 | */ |
|
| 15 | class InvalidRequestStackMiddlewareException extends InvalidDataTypeException |
|
| 16 | { |
|
| 17 | ||
| 18 | /** |
|
| 19 | * @param mixed $middleware_app_class |
|
| 20 | * @param string $message |
|
| 21 | * @param int $code |
|
| 22 | * @param Exception $previous |
|
| 23 | */ |
|
| 24 | public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null) |
|
| 25 | { |
|
| 26 | if (is_array($middleware_app_class)) { |
|
| 27 | $middleware_app_class = reset($middleware_app_class); |
|
| 28 | } |
|
| 29 | if (empty($message)) { |
|
| 30 | $message = sprintf( |
|
| 31 | esc_html__( |
|
| 32 | 'The supplied Request Stack Middleware class "%1$s" is invalid or could no be found.', |
|
| 33 | 'event_espresso' |
|
| 34 | ), |
|
| 35 | $middleware_app_class |
|
| 36 | ); |
|
| 37 | } |
|
| 38 | parent::__construct( |
|
| 39 | '$middleware_app_class', |
|
| 40 | $middleware_app_class, |
|
| 41 | 'EventEspresso\core\services\request\middleware\Middleware', |
|
| 42 | $message, |
|
| 43 | $code, |
|
| 44 | $previous |
|
| 45 | ); |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||
| @@ 13-43 (lines=31) @@ | ||
| 10 | * @author Brent Christensen |
|
| 11 | * @since 4.9.0 |
|
| 12 | */ |
|
| 13 | class InvalidEntityException extends \InvalidArgumentException |
|
| 14 | { |
|
| 15 | ||
| 16 | /** |
|
| 17 | * InvalidInterfaceException constructor. |
|
| 18 | * |
|
| 19 | * @param string $actual classname of what we got |
|
| 20 | * @param string $expected classname of the entity we wanted |
|
| 21 | * @param string $message |
|
| 22 | * @param int $code |
|
| 23 | * @param \Exception $previous |
|
| 24 | */ |
|
| 25 | public function __construct($actual, $expected, $message = '', $code = 0, \Exception $previous = null) |
|
| 26 | { |
|
| 27 | if (empty($message)) { |
|
| 28 | $message = sprintf( |
|
| 29 | __( |
|
| 30 | 'The supplied entity is an instance of "%1$s", but an instance of "%2$s" was expected. Object: %3$s', |
|
| 31 | 'event_espresso' |
|
| 32 | ), |
|
| 33 | is_object($actual) |
|
| 34 | ? get_class($actual) |
|
| 35 | : gettype($actual), |
|
| 36 | $expected, |
|
| 37 | var_export($actual, true) |
|
| 38 | ); |
|
| 39 | } |
|
| 40 | parent::__construct($message, $code, $previous); |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||