/** * Constructs a new SagaEntry for the given <code>saga</code>. The given saga must be serializable. The provided * saga is not modified by this operation. * * @param SagaInterface $saga The saga to store * @param SerializerInterface $serializer The serialization mechanism to convert the Saga to a byte stream */ public function __construct(SagaInterface $saga, SerializerInterface $serializer) { $this->sagaId = $saga->getSagaIdentifier(); $serialized = $serializer->serialize($saga); $this->serializedSaga = $serialized->getData(); $this->sagaType = $serialized->getType()->getName(); $this->revision = $serialized->getType()->getRevision(); $this->saga = $saga; }
/** * Constructs a message containing a reply to the command with given <code>commandIdentifier</code>, containing * either given <code>returnValue</code> or <code>error</code>, which uses the given <code>serializer</code> to * deserialize its contents. * * @param string $commandIdentifier The identifier of the command to which the message is a reply * @param SerializerInterface $serializer The serializer to serialize the message contents with * @param mixed $returnValue The return value of command process * @param bool $success <code>true</code> if the returnValue represents the completion of the command <code>false</code> otherwise */ public function __construct($commandIdentifier, SerializerInterface $serializer, $returnValue, $success = true) { $this->success = $success; $this->result = null; if (null === $returnValue) { $this->result = null; } elseif ($returnValue instanceof \Exception) { $this->result = $serializer->serialize($returnValue->getMessage()); } else { $this->result = $serializer->serialize($returnValue); } $this->commandIdentifier = $commandIdentifier; if (null !== $this->result) { $this->resultType = $this->result->getType()->getName(); $this->resultRevision = $this->result->getType()->getRevision(); $this->serializedResult = $this->result->getData(); } }
/** * Constructs a new SagaEntry for the given <code>saga</code>. The given saga must be serializable. The provided * saga is not modified by this operation. * * @param SagaInterface $saga The saga to store * @param SerializerInterface $serializer The serialization mechanism to convert the Saga to a byte stream */ public function __construct(SagaInterface $saga, SerializerInterface $serializer) { $this->sagaId = $saga->getSagaIdentifier(); $serialized = $serializer->serialize($saga); $this->serializedSaga = $serialized->getData(); $this->sagaType = get_class($saga); $this->saga = $saga; $this->associationValues = $saga->getAssociationValues()->asArray(); }