Skip to content

Commit 49ed446

Browse files
committed
entity docs
1 parent afa7a99 commit 49ed446

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

‎docs/ddd/entities.md‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Entities
2+
3+
Entity objects are provided per domain layer and usually follow a [POPO](https://stackoverflow.com/questions/41188002/what-does-the-term-plain-old-php-object-popo-exactly-mean)
4+
design.
5+
6+
To simplify the creation of entities the base domain layer provides common fields and features in the form of PHP
7+
traits. Entity fields can be compared to a read-operation, whereas entity features represent a write-operation.
8+
9+
They are defined in a dedicated namespace for discovery, respectively `Msgphp\Domain\Entiy\Field\` and
10+
`MsgPhp\Domain\Entity\Features\`.
11+
12+
## Common entity fields
13+
14+
### `CreatedAtField`
15+
16+
A datetime value representing the entity was initially created at.
17+
18+
- `getCreatedAt(): \DateTimeInterface`
19+
- Required to be set initially
20+
21+
### `EnabledField`
22+
23+
A boolean value representing the entity should be considered enabled yes or no.
24+
25+
- `isEnabled(): bool`
26+
- `false` by default
27+
28+
### `LastUpdatedAtField`
29+
30+
A datetime value representing the entity was last updated at.
31+
32+
- `getLastUpdatedAt(): \DateTimeInterface`
33+
- Required to be set initially
34+
35+
## Common entity features
36+
37+
### `CanBeConfirmed`
38+
39+
Provides ability to confirm an entity. When used an entity is considered initially unconfirmed.
40+
41+
- `getConfirmationToken(): ?string`
42+
- Required to be set initially
43+
- `getConfirmedAt(): ?\DateTimeInterface`
44+
- `isConfirmed(): bool`
45+
- `confirm(): void`
46+
- `confirmationToken` is unset
47+
- `confirmatedAt` is set to current datetime
48+
49+
### `CanBeEnabled`
50+
51+
Provides ability to toggle an entity availability state.
52+
53+
- Inherits from `EnabledField`
54+
- `enable(): void`
55+
- `disable(): void`

‎docs/ddd/repositories.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ A repository is not interface bound by default. Instead you can leverage various
44
depending on the type of infrastructure needed. By design they follow the same API although there might be subtle
55
differences per implementation.
66

7+
Note default (interface bound) repositories are provided per domain layer.
8+
79
## Implementations
810

911
- `MsgPhp\Domain\Infra\InMemory\DomainEntityRepositoryTrait` (In-memory persistence)

‎mkdocs.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ pages:
2222
- Entity factory: ddd/factory/entity.md
2323
- Static factory: ddd/factory/static.md
2424
- Repositories: ddd/repositories.md
25+
- Entities: ddd/entities.md

0 commit comments

Comments
 (0)