mailpoet
/
vendor-prefixed
/
symfony
/
dependency-injection
/
Exception
/
AutowiringFailedException.php
AutowiringFailedException.php
2 years ago
BadMethodCallException.php
4 years ago
EnvNotFoundException.php
4 years ago
EnvParameterException.php
2 years ago
ExceptionInterface.php
4 years ago
InvalidArgumentException.php
4 years ago
InvalidParameterTypeException.php
4 years ago
LogicException.php
4 years ago
OutOfBoundsException.php
4 years ago
ParameterCircularReferenceException.php
2 years ago
ParameterNotFoundException.php
2 years ago
RuntimeException.php
4 years ago
ServiceCircularReferenceException.php
2 years ago
ServiceNotFoundException.php
2 years ago
index.php
3 years ago
AutowiringFailedException.php
50 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\DependencyInjection\Exception; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | class AutowiringFailedException extends RuntimeException |
| 5 | { |
| 6 | private $serviceId; |
| 7 | private $messageCallback; |
| 8 | public function __construct(string $serviceId, $message = '', int $code = 0, ?\Throwable $previous = null) |
| 9 | { |
| 10 | $this->serviceId = $serviceId; |
| 11 | if ($message instanceof \Closure && \function_exists('xdebug_is_enabled') && \xdebug_is_enabled()) { |
| 12 | $message = $message(); |
| 13 | } |
| 14 | if (!$message instanceof \Closure) { |
| 15 | parent::__construct($message, $code, $previous); |
| 16 | return; |
| 17 | } |
| 18 | $this->messageCallback = $message; |
| 19 | parent::__construct('', $code, $previous); |
| 20 | $this->message = new class($this->message, $this->messageCallback) |
| 21 | { |
| 22 | private $message; |
| 23 | private $messageCallback; |
| 24 | public function __construct(&$message, &$messageCallback) |
| 25 | { |
| 26 | $this->message =& $message; |
| 27 | $this->messageCallback =& $messageCallback; |
| 28 | } |
| 29 | public function __toString() : string |
| 30 | { |
| 31 | $messageCallback = $this->messageCallback; |
| 32 | $this->messageCallback = null; |
| 33 | try { |
| 34 | return $this->message = $messageCallback(); |
| 35 | } catch (\Throwable $e) { |
| 36 | return $this->message = $e->getMessage(); |
| 37 | } |
| 38 | } |
| 39 | }; |
| 40 | } |
| 41 | public function getMessageCallback() : ?\Closure |
| 42 | { |
| 43 | return $this->messageCallback; |
| 44 | } |
| 45 | public function getServiceId() |
| 46 | { |
| 47 | return $this->serviceId; |
| 48 | } |
| 49 | } |
| 50 |