Skip to content

Commit

Permalink
Create hash on demand if no is available yet
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk committed Oct 12, 2022
1 parent c04cc69 commit f153fef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/Chronicler.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,8 @@ public function record(Record $record): void

public function isRecorded(Record $record, string $period = null): bool
{
if (!$hash = $record->getHash()) {
return false;
}

$result = $this->recordRepository->findOneBy(function($qb) use ($hash, $period) {
$qb->andWhere('e.hash = :hash')->setParameter('hash', $hash);
$result = $this->recordRepository->findOneBy(function($qb) use ($record, $period) {
$qb->andWhere('e.hash = :hash')->setParameter('hash', $record->getHash());

if (is_null($period)) {
return $qb;
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ public function getNote(): ?string
}


public function getHash(): ?string
public function getHash(): string
{
return $this->hash;
return $this->hash ?: $this->createUniqueHash();
}


Expand Down

0 comments on commit f153fef

Please sign in to comment.