-1

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?

Timor Kodal
  • 324
  • 3
  • 7
  • Are you using [`stof/doctrine-extensions-bundle`](https://symfony.com/doc/current/bundles/StofDoctrineExtensionsBundle/index.html)? It claims to function with Symfony 4.4 - 5.2 and is a method for integrating Gedmo with Symfony. – Will B. Jun 01 '21 at 14:34
  • 2
    You have to [configure the listeners](https://symfony.com/doc/current/bundles/StofDoctrineExtensionsBundle/configuration.html#activate-the-extensions-you-want) for each extension. – msg Jun 01 '21 at 14:44
  • @WillB. Yes, I have implemented and activated the doctrine-extensions-bundle. – Timor Kodal Jun 02 '21 at 08:49
  • Thanks @msg. Adjusting the stof_doctrine_extensions.yaml did the trick: stof_doctrine_extensions: default_locale: en_US orm: default: tree: true timestampable: true softdeleteable: true – Timor Kodal Jun 02 '21 at 09:01

1 Answers1

2

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
Timor Kodal
  • 324
  • 3
  • 7