Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
common/src/Messaging/MessageFactory.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
36 lines (32 sloc)
1.3 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This file is part of prooph/common. | |
* (c) 2014-2022 Alexander Miertsch <kontakt@codeliner.ws> | |
* (c) 2015-2022 Sascha-Oliver Prolic <saschaprolic@googlemail.com> | |
* | |
* For the full copyright and license information, please view the LICENSE | |
* file that was distributed with this source code. | |
*/ | |
declare(strict_types=1); | |
namespace Prooph\Common\Messaging; | |
interface MessageFactory | |
{ | |
/** | |
* Message data MUST contain at least a "payload" key | |
* but may also contain "uuid", "message_name", "metadata", and "created_at". | |
* | |
* In general the message factory MUST support creating event objects from an array returned by | |
* the corresponding Prooph\Common\Messaging\MessageConverter | |
* | |
* You can use the assertion helper Prooph\Common\Messaging\MessageDataAssertion to assert message data | |
* before processing it. | |
* | |
* If one of the optional keys is not part of the message data the factory should use a default instead: | |
* For example: | |
* uuid = Uuid::uuid4() | |
* message_name = $messageName //First parameter passed to the method | |
* metadata = [] | |
* created_at = new \DateTimeImmutable('now', new \DateTimeZone('UTC')) //We treat all dates as UTC | |
*/ | |
public function createMessageFromArray(string $messageName, array $messageData): Message; | |
} |