85b781656333 — Eddie Barraco 5 years ago
Entity updated at now trigger
M config/packages/doctrine/Article.orm.xml +1 -0
@@ 8,6 8,7 @@ 
 
         <lifecycle-callbacks>
             <lifecycle-callback type="prePersist" method="onPrePersist"/>
+            <lifecycle-callback type="preUpdate" method="onPreUpdate"/>
         </lifecycle-callbacks>
 
         <id name="id" column="id" type="uuid">

          
M config/packages/doctrine/Tag.orm.xml +1 -0
@@ 8,6 8,7 @@ 
 
         <lifecycle-callbacks>
             <lifecycle-callback type="prePersist" method="onPrePersist"/>
+            <lifecycle-callback type="preUpdate" method="onPreUpdate"/>
         </lifecycle-callbacks>
 
         <id name="id" column="id" type="uuid">

          
M src/Entity/Article.php +5 -0
@@ 39,6 39,11 @@ class Article
         $this->updatedAt = $date;
     }
 
+    public function onPreUpdate()
+    {
+        $this->updatedAt = new \DateTime();
+    }
+
     public function getId(): ?Uuid
     {
         return $this->id;

          
M src/Entity/Tag.php +5 -0
@@ 18,6 18,11 @@ class Tag
         $this->updatedAt = $date;
     }
 
+    public function onPreUpdate()
+    {
+        $this->updatedAt = new \DateTime();
+    }
+
     public function getCsvProofLabel(?string $enclosure = '"')
     {
         if (preg_match('/ /', $this->label)) {