Skip to content

Commit

Permalink
dev: Add isCreatedBy and isUpdatedBy to the MetaEntityInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
marien-probesys committed Aug 18, 2023
1 parent 0bb57c4 commit e9801be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Entity/MetaEntityInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ public function getCreatedBy(): ?User;

public function setCreatedBy(?User $createdBy): self;

public function isCreatedBy(User $user): bool;

public function getUpdatedAt(): ?\DateTimeImmutable;

public function setUpdatedAt(\DateTimeImmutable $updatedAt): self;

public function getUpdatedBy(): ?User;

public function setUpdatedBy(?User $updatedBy): self;

public function isUpdatedBy(User $user): bool;
}
16 changes: 16 additions & 0 deletions src/Entity/MetaEntityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public function setCreatedBy(?User $createdBy): self
return $this;
}

public function isCreatedBy(User $user): bool
{
return (
$this->createdBy !== null &&
$this->createdBy->getId() === $user->getId()
);
}

public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
Expand All @@ -67,4 +75,12 @@ public function setUpdatedBy(?User $updatedBy): self

return $this;
}

public function isUpdatedBy(User $user): bool
{
return (
$this->updatedBy !== null &&
$this->updatedBy->getId() === $user->getId()
);
}
}

0 comments on commit e9801be

Please sign in to comment.