Is there a replacement for the Doctrine Gedmo-Extension (Timestampable, Softdeletable ...) in Symfony 5?

2.4k views Asked by At

With prior versions of Symfony (<5), it was possible to automatically populate DateTime-fields on creation or when updating existing entries.

Example:

    /**
     * @var \DateTime $createdAt
     * @Gedmo\Timestampable(on="create")
     * @ORM\Column(type="datetime")
     */
    private $createdAt;

These annotations do not seem to have any effect if applied onto an Entity in a Symfony5 project. Has a replacement for the Gedmo-extension been released or is there a workaround to be used to avoid manually setting data fields with a current timestamp?

1

There are 1 answers

0
Timor Kodal On

Editing /config/packages/stof_doctrine_extensions.yaml did the trick. I had to activate the timestampable-listener:

stof_doctrine_extensions:
    default_locale: en_US
    orm:
        default:
            tree: true
            timestampable: true
            softdeleteable: true