mirror of
https://github.com/danog/Valinor.git
synced 2024-11-27 04:34:48 +01:00
ad1207153e
The `\CuyZ\Valinor\Mapper\Tree\Message\Message` interface is no longer a `Stringable`, however it defines a new method `body` that must return the body of the message, which can contain placeholders that will be replaced by parameters. These parameters can now be defined by implementing the interface `\CuyZ\Valinor\Mapper\Tree\Message\HasParameters`. This leads to the deprecation of the no longer needed interface `\CuyZ\Valinor\Mapper\Tree\Message\TranslatableMessage` which had a confusing name. ```php final class SomeException extends DomainException implements ErrorMessage, HasParameters, HasCode { private string $someParameter; public function __construct(string $someParameter) { parent::__construct(); $this->someParameter = $someParameter; } public function body() : string { return 'Some message / {some_parameter} / {source_value}'; } public function parameters(): array { return [ 'some_parameter' => $this->someParameter, ]; } public function code() : string { // A unique code that can help to identify the error return 'some_unique_code'; } } ``` |
||
---|---|---|
.. | ||
Object | ||
Source | ||
Tree | ||
MappingErrorTest.php | ||
TreeMapperContainerTest.php |