Skip to content

AErmolenko/hw20#124

Open
Alexey-Ermolenko wants to merge 2 commits into
mainfrom
AErmolenko/hw20
Open

AErmolenko/hw20#124
Alexey-Ermolenko wants to merge 2 commits into
mainfrom
AErmolenko/hw20

Conversation

@Alexey-Ermolenko

Copy link
Copy Markdown

No description provided.

Comment thread src/Controller/RequestController.php Outdated
}

$entity = new ProcessingRequest($data['payload']);
$em->persist($entity);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Подобные вещи для работы с сущностью правильнее вынести как раз в EntityRepository, раз уж репозитории используются - они как раз для этого

Comment thread src/Entity/ProcessingRequest.php Outdated
public function setStatus(RequestStatus $status): void
{
$this->status = $status;
$this->updatedAt = new \DateTimeImmutable();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для подобного (раз мы на Symfony опираемся) существует атрибут класса #[ORM\HasLifecycleCallbacks].
Выглядело бы примерно так:

#[ORM\PreUpdate]
public function onUpdated(): void {
        $this->updatedAt = new \DateTimeImmutable();
}

без повторений $this->updatedAt = ...
Это не ошибка, просто совет для Doctrine-стиля.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants