mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Feature: force to add updatedAt and createdAt even if no user iss associated
This commit is contained in:
parent
722f053f06
commit
fcbc00d0f1
@ -41,12 +41,12 @@ class TrackCreateUpdateSubscriber implements EventSubscriber
|
|||||||
{
|
{
|
||||||
$object = $args->getObject();
|
$object = $args->getObject();
|
||||||
|
|
||||||
if (
|
if ($object instanceof TrackCreationInterface) {
|
||||||
$object instanceof TrackCreationInterface
|
|
||||||
&& $this->security->getUser() instanceof User
|
|
||||||
) {
|
|
||||||
$object->setCreatedBy($this->security->getUser());
|
|
||||||
$object->setCreatedAt(new DateTimeImmutable('now'));
|
$object->setCreatedAt(new DateTimeImmutable('now'));
|
||||||
|
|
||||||
|
if ($this->security->getUser() instanceof User) {
|
||||||
|
$object->setCreatedBy($this->security->getUser());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->onUpdate($object);
|
$this->onUpdate($object);
|
||||||
@ -61,12 +61,12 @@ class TrackCreateUpdateSubscriber implements EventSubscriber
|
|||||||
|
|
||||||
protected function onUpdate(object $object): void
|
protected function onUpdate(object $object): void
|
||||||
{
|
{
|
||||||
if (
|
if ($object instanceof TrackUpdateInterface) {
|
||||||
$object instanceof TrackUpdateInterface
|
$object->setUpdatedAt(new DateTimeImmutable('now'));
|
||||||
&& $this->security->getUser() instanceof User
|
|
||||||
) {
|
if ($this->security->getUser() instanceof User) {
|
||||||
$object->setUpdatedBy($this->security->getUser());
|
$object->setUpdatedBy($this->security->getUser());
|
||||||
$object->setUpdatedAt(new DateTimeImmutable('now'));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user