Skip to content

Commit 6920a8b

Browse files
committed
add taggable doctrine store
1 parent ca86f10 commit 6920a8b

7 files changed

Lines changed: 1471 additions & 2 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ phpunit-integration: vendor
4141

4242
.PHONY: phpunit-integration-postgres
4343
phpunit-integration-postgres: vendor ## run phpunit integration tests on postgres
44-
DB_URL="pdo-pgsql://postgres:postgres@localhost:5432/eventstore?charset=utf8" vendor/bin/phpunit --testsuite=integration
44+
DB_URL="pdo-pgsql://postgres:postgres@127.0.0.1:5432/eventstore?charset=utf8" vendor/bin/phpunit --testsuite=integration
4545

4646
.PHONY: phpunit-integration-mysql
4747
phpunit-integration-mysql: vendor ## run phpunit integration tests on mysql
48-
DB_URL="pdo-mysql://root@localhost:3306/eventstore?charset=utf8" vendor/bin/phpunit --testsuite=integration
48+
DB_URL="pdo-mysql://root@127.0.0.1:3306/eventstore?charset=utf8" vendor/bin/phpunit --testsuite=integration
4949

5050
.PHONY: phpunit-unit
5151
phpunit-unit: vendor ## run phpunit unit tests

src/Metadata/Message/MessageHeaderRegistry.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Patchlevel\EventSourcing\Store\Header\PlayheadHeader;
1212
use Patchlevel\EventSourcing\Store\Header\RecordedOnHeader;
1313
use Patchlevel\EventSourcing\Store\Header\StreamNameHeader;
14+
use Patchlevel\EventSourcing\Store\Header\TagsHeader;
1415
use Patchlevel\EventSourcing\Store\StreamStartHeader;
1516

1617
use function array_flip;
@@ -85,6 +86,7 @@ public static function createWithInternalHeaders(array $headerNameToClassMap = [
8586
'newStreamStart' => StreamStartHeader::class,
8687
'eventId' => EventIdHeader::class,
8788
'index' => IndexHeader::class,
89+
'tags' => TagsHeader::class,
8890
];
8991

9092
return new self($headerNameToClassMap + $internalHeaders);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Patchlevel\EventSourcing\Store\Criteria;
6+
7+
use InvalidArgumentException;
8+
9+
use function array_unique;
10+
use function array_values;
11+
12+
final class TagCriterion
13+
{
14+
/** @var list<string> */
15+
public readonly array $tags;
16+
17+
public function __construct(
18+
string ...$tags,
19+
) {
20+
$this->tags = array_values(array_unique($tags));
21+
22+
if ($this->tags === []) {
23+
throw new InvalidArgumentException('At least one tag must be provided.');
24+
}
25+
}
26+
}

src/Store/Header/TagsHeader.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Patchlevel\EventSourcing\Store\Header;
6+
7+
/** @psalm-immutable */
8+
class TagsHeader
9+
{
10+
/** @param list<string> $tags */
11+
public function __construct(
12+
public readonly array $tags,
13+
) {
14+
}
15+
}

0 commit comments

Comments
 (0)