i try to make timestampable entity with StofDoctrineExtension. Unfortunatly i found that using trait works perfectly, but not using attributes.
Could someone says me what i does wrong ?
this works :
<?php
namespace App\Entity;
use App\Repository\UserPictureRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
#[ORM\Entity(repositoryClass: UserPictureRepository::class)]
#[ORM\HasLifecycleCallbacks]
class UserPicture
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
use TimestampableEntity;
this doesn't work (timestampable is ignorated when i persist entity):
<?php
namespace App\Entity;
use App\Repository\UserPictureRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
#[ORM\Entity(repositoryClass: UserPictureRepository::class)]
#[ORM\HasLifecycleCallbacks]
class UserPicture
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
#[Gedmo\Timestampable(on: 'create')]
private ?\DateTimeInterface $created = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
#[Gedmo\Timestampable]
private ?\DateTimeInterface $updated = null;