<?php
# src/Entity/MyTimestampableEntity.php
namespace App\Entity;
use Cloudstek\DoctrineBehaviour\TimestampableInterface;
use Cloudstek\DoctrineBehaviour\TimestampableTrait;
class MyTimestampableEntity implements TimestampableInterface
{
use TimestampableTrait;
// ... Your entity code here.
}
<?php
# src/MyClass.php
namespace App;
use App\Entity\MyTimestampableEntity;
class MyClass
{
// ...
function doWhatever() {
$em = $this->getEntityManager();
$entity = new MyTimestampableEntity();
$em->persist($entity);
$em->flush();
// Entity will now have created and updated timestamps set.
}
}