/** * @param Uuid $messageId * @return null|MessageLogEntry */ public function getEntryForMessageId(Uuid $messageId) { if (isset($this->entriesByMessageId[$messageId->toString()])) { return $this->entriesByMessageId[$messageId->toString()]; } $query = $this->connection->createQueryBuilder(); $query->select('*')->from(self::TABLE_NAME)->where($query->expr()->eq('message_id', ':message_id')); $query->setParameter('message_id', $messageId->toString()); $entryData = $query->execute()->fetch(\PDO::FETCH_ASSOC); if (!$entryData) { return null; } $entry = MessageLogEntry::fromArray($entryData); $this->entriesByMessageId[$messageId->toString()] = $entry; return $entry; }
/** * @param Uuid $id */ public function find(Uuid $id) { $teamMember = $this->database->getRecord('SELECT * FROM team_members WHERE id = :id', ['id' => $id->getBytes()]); if (empty($teamMember)) { throw new \Exception('No teammember with id ' . $id->toString() . 'found'); } return TeamMember::fromArray($teamMember); }
/** * {@inheritdoc} */ public function hasAssetMapping(Uuid $uuid) { $expr = Expr::method('getUuid', Expr::method('toString', Expr::same($uuid->toString())))->andX($this->exprBuilder->buildExpression()); return $this->discoveryManager->hasBindingDescriptors($expr); }
public function serializeUuid(VisitorInterface $visitor, Uuid $uuid, array $type, Context $context) { return $visitor->visitString($uuid->toString(), $type, $context); }
/** * Return the object as a string * * @return string */ public function __toString() { return $this->value->toString(); }
/** * {@inheritdoc} */ public function getBinding(Uuid $uuid) { if (!isset($this->bindings[$uuid->toString()])) { throw NoSuchBindingException::forUuid($uuid); } return $this->bindings[$uuid->toString()]; }
/** * {@inheritdoc} */ public function getBinding(Uuid $uuid) { if (!isset($this->keysByUuid[$uuid->toString()])) { throw NoSuchBindingException::forUuid($uuid); } $key = $this->keysByUuid[$uuid->toString()]; if (!isset($this->bindingsByKey[$key])) { $this->loadBindingsForKey($key); } foreach ($this->bindingsByKey[$key] as $binding) { if ($binding->getUuid()->equals($uuid)) { return $binding; } } // This does not happen except if someone plays with the key-value store // contents (or there's a bug here..) throw new RuntimeException('The discovery is corrupt. Please rebuild it.'); }
public function testActionId() { $this->assertEquals($this->uuid->toString(), $this->command->actionId()->toString()); }
/** * Returns whether a binding descriptor exists. * * @param Uuid $uuid The UUID of the binding descriptor. * * @return bool Returns `true` if a binding descriptor was set for the given * UUID. */ public function contains(Uuid $uuid) { return isset($this->map[$uuid->toString()]); }
private function uuid(Uuid $uuid) { return $this->defaultExpr()->andSame($uuid->toString(), BindingDescriptor::UUID); }
public function getValue() { return $this->uuid->toString(); }
protected function setUp() { $this->uuid = Uuid::uuid4(); $this->createdAt = new \DateTimeImmutable('now', new \DateTimeZone('UTC')); $this->command = DoSomething::fromArray(['message_name' => 'TestCommand', 'uuid' => $this->uuid->toString(), 'version' => 1, 'created_at' => $this->createdAt, 'payload' => ['command' => 'payload'], 'metadata' => ['command' => 'metadata']]); }
/** * Creates an exception for a UUID. * * @param Uuid $uuid The UUID of the binding. * @param Exception|null $cause The exception that caused this exception. * * @return static The created exception. */ public static function forUuid(Uuid $uuid, Exception $cause = null) { return new static(sprintf('The binding "%s" does not exist.', $uuid->toString()), 0, $cause); }
/** * Returns whether the binding descriptor exists in this file. * * @param Uuid $uuid The UUID of the binding descriptor. * * @return bool Whether the file contains the binding descriptor. */ public function hasBindingDescriptor(Uuid $uuid) { return isset($this->bindingDescriptors[$uuid->toString()]); }
protected function setUp() { $this->uuid = Uuid::uuid4(); $this->createdAt = new \DateTimeImmutable(); $this->domainEvent = SomethingWasDone::fromArray(['message_name' => 'TestDomainEvent', 'uuid' => $this->uuid->toString(), 'version' => 1, 'created_at' => $this->createdAt->format(\DateTime::ISO8601), 'payload' => ['event' => 'payload'], 'metadata' => ['event' => 'metadata']]); }
/** * Creates an exception for a duplicate UUID. * * @param Uuid $uuid The UUID. * @param Exception|null $cause The exception that caused this exception. * * @return static The created exception. */ public static function forUuid(Uuid $uuid, Exception $cause = null) { return new static(sprintf('A binding with UUID "%s" exists already.', $uuid->toString()), 0, $cause); }
/** * Returns whether the binding matches the given expression. * * @param Expression $expr The search criteria. You can use the fields * {@link UUID}, {@link QUERY}, {@link LANGUAGE}, * {@link TYPE_NAME}, {@link STATE} and * {@link CONTAINING_PACKAGE} in the expression. * * @return bool Returns `true` if the binding matches the expression and * `false` otherwise. */ public function match(Expression $expr) { return $expr->evaluate(array(self::UUID => $this->uuid->toString(), self::QUERY => $this->query, self::LANGUAGE => $this->language, self::TYPE_NAME => $this->typeName, self::PARAMETER_VALUES => $this->parameterValues, self::STATE => $this->state, self::CONTAINING_PACKAGE => $this->containingPackage->getName())); }
/** * Creates an exception for a UUID that was not found in a given package. * * @param Uuid $uuid The UUID. * @param string $packageName The name of the containing package. * @param Exception $cause The exception that caused this exception. * * @return static The created exception. */ public static function forUuidAndPackage(Uuid $uuid, $packageName, Exception $cause = null) { return new static(sprintf('The binding with UUID "%s" does not exist in package "%s".', $uuid->toString(), $packageName), 0, $cause); }
/** * Returns an array copy of this message * * @return array */ public function toArray() { return ['message_name' => $this->messageName, 'uuid' => $this->uuid->toString(), 'version' => $this->version, 'payload' => $this->payload(), 'metadata' => $this->metadata, 'created_at' => $this->createdAt()]; }
/** * Creates an exception for a UUID that exists already. * * @param Uuid $uuid The UUID of the mapping. * @param Exception|null $cause The exception that caused this exception. * * @return static The created exception. */ public static function forUuid(Uuid $uuid, Exception $cause = null) { return new static(sprintf('The asset mapping "%s" exists already.', $uuid->toString()), 0, $cause); }
/** * Creates an exception for a binding UUID that could not be disabled in the * root package. * * @param Uuid $uuid The UUID. * @param string $packageName The name of the package. * @param Exception $cause The exception that caused this exception. * * @return static The created exception. */ public static function cannotDisableBinding(Uuid $uuid, $packageName, Exception $cause = null) { return new static(sprintf('Cannot disable binding "%s" in package "%s": Can only disable ' . 'bindings in non-root packages.', $uuid->toString(), $packageName), 0, $cause); }
/** * Returns whether the resource binding is disabled. * * @param Uuid $uuid The UUID of the resource binding. * * @return bool Whether the resource binding is disabled. */ public function hasDisabledBindingUuid(Uuid $uuid) { return isset($this->disabledBindingUuids[$uuid->toString()]); }
/** * @param Uuid $uuid * @return User */ public function get(Uuid $uuid) { return $this->getAggregateRoot($uuid->toString()); }
/** * @return string */ public function toString() { return $this->uuid->toString(); }
protected function preSerialize(array &$data) { $data[] = $this->typeName; $data[] = $this->userParameterValues; $data[] = $this->uuid->toString(); }