DoDomuDojade Documentation

Announcement
in package

FinalYes

Announcement Entity Aggregate Root for Announcement domain

Table of Contents

Properties

$decidedAt  : DateTimeImmutable|null
$decidedBy  : int|null
$status  : AnnouncementStatus
$text  : string
$title  : string
$validUntil  : DateTimeImmutable
$createdAt  : DateTimeImmutable
$events  : array<string|int, mixed>
$id  : AnnouncementId|null
$userId  : int|null

Methods

__construct()  : mixed
approve()  : void
Change status to approved
clearDomainEvents()  : void
create()  : self
Creates a new announcement <br> Announcement is approved by default
fromArray()  : self
Hydrate from database array
getCreatedAt()  : DateTimeImmutable
getDomainEvents()  : array<string|int, mixed>
getId()  : AnnouncementId|null
getUserId()  : int|null
isValid()  : bool
Checks if an announcement is valid - Status must be APPROVED - Valid until date must be in the future
proposeNew()  : self
Proposes a new announcement
reject()  : void
Change status to rejected
toArray()  : array<string|int, mixed>
Serialize to array (for database storage)
update()  : void
Updates announcement data
recordEvent()  : void

Properties

$decidedAt

public DateTimeImmutable|null $decidedAt = null
Hooks
public DateTimeImmutable|null get public set

$decidedBy

public int|null $decidedBy = null
Hooks
public int|null get public set

$validUntil

public DateTimeImmutable $validUntil
Hooks
public DateTimeImmutable get

$createdAt read-only

private DateTimeImmutable $createdAt

Methods

__construct()

public __construct(AnnouncementId|null $id, string $title, string $text, DateTimeImmutable $createdAt, DateTimeImmutable $validUntil, int|null $userId[, AnnouncementStatus $status = AnnouncementStatus::PENDING ][, DateTimeImmutable|null $decidedAt = null ][, int|null $decidedBy = null ]) : mixed
Parameters
$id : AnnouncementId|null
$title : string
$text : string
$createdAt : DateTimeImmutable
$validUntil : DateTimeImmutable
$userId : int|null
$status : AnnouncementStatus = AnnouncementStatus::PENDING
$decidedAt : DateTimeImmutable|null = null
$decidedBy : int|null = null

approve()

Change status to approved

public approve(int $decidedBy) : void
Parameters
$decidedBy : int

create()

Creates a new announcement <br> Announcement is approved by default

public static create(string $title, string $text, DateTimeImmutable $validUntil, int $userId) : self
Parameters
$title : string
$text : string
$validUntil : DateTimeImmutable
$userId : int
Return values
self

fromArray()

Hydrate from database array

public static fromArray(array<string|int, mixed> $data) : self
Parameters
$data : array<string|int, mixed>
Return values
self

getCreatedAt()

public getCreatedAt() : DateTimeImmutable
Return values
DateTimeImmutable

getDomainEvents()

public getDomainEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>

getUserId()

public getUserId() : int|null
Return values
int|null

isValid()

Checks if an announcement is valid - Status must be APPROVED - Valid until date must be in the future

public isValid() : bool
Return values
bool

proposeNew()

Proposes a new announcement

public static proposeNew(string $title, string $text, DateTimeImmutable $validUntil) : self
Parameters
$title : string
$text : string
$validUntil : DateTimeImmutable
Tags
throws
DateMalformedStringException
Return values
self

reject()

Change status to rejected

public reject(int $decidedBy) : void
Parameters
$decidedBy : int

toArray()

Serialize to array (for database storage)

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

update()

Updates announcement data

public update(string $title, string $text, DateTimeImmutable $validUntil[, AnnouncementStatus|null $status = null ][, int|null $decidedBy = null ]) : void
Parameters
$title : string
$text : string
$validUntil : DateTimeImmutable
$status : AnnouncementStatus|null = null
$decidedBy : int|null = null
Tags
throws
DateMalformedStringException

        
On this page

Search results