EmptyNameException.php
4 years ago
NameCollisionException.php
2 years ago
ReferenceNodeNotFoundException.php
4 years ago
TypeNotSupported.php
3 years ago
NameCollisionException.php
67 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Framework\FieldsAPI\Exceptions; |
| 4 | |
| 5 | use Give\Framework\Exceptions\Primitives\Exception; |
| 6 | use Give\Framework\FieldsAPI\Contracts\Node; |
| 7 | |
| 8 | /** |
| 9 | * @since 2.32.0 add existing and incoming nodes to exception |
| 10 | * @since 2.10.2 |
| 11 | */ |
| 12 | class NameCollisionException extends Exception |
| 13 | { |
| 14 | /** |
| 15 | * @var string |
| 16 | */ |
| 17 | protected $nodeNameCollision; |
| 18 | /** |
| 19 | * @var Node |
| 20 | */ |
| 21 | protected $existingNode; |
| 22 | /** |
| 23 | * @var Node |
| 24 | */ |
| 25 | protected $incomingNode; |
| 26 | |
| 27 | public function __construct( |
| 28 | string $name, |
| 29 | Node $existingNode, |
| 30 | Node $incomingNode, |
| 31 | int $code = 0, |
| 32 | Exception $previous = null |
| 33 | ) |
| 34 | { |
| 35 | $this->nodeNameCollision = $name; |
| 36 | $this->existingNode = $existingNode; |
| 37 | $this->incomingNode = $incomingNode; |
| 38 | |
| 39 | $message = "Node name collision for $name"; |
| 40 | parent::__construct($message, $code, $previous); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @since 2.32.0 |
| 45 | */ |
| 46 | public function getNodeNameCollision(): string |
| 47 | { |
| 48 | return $this->nodeNameCollision; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * @since 2.32.0 |
| 53 | */ |
| 54 | public function getIncomingNode(): Node |
| 55 | { |
| 56 | return $this->incomingNode; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * @since 2.32.0 |
| 61 | */ |
| 62 | public function getExistingNode(): Node |
| 63 | { |
| 64 | return $this->existingNode; |
| 65 | } |
| 66 | } |
| 67 |