title: Automatically updating created_by in the model
body: <p>I wanted to have a created_by field for my model, say Product, that is automatically updated and I am using FOSUserBundle and Doctrine2. What is the recommended way of inputting the User id into Product?</p>
  
  <p>Can I do it in the Product model? I am not sure how to do so and any help would be wonderful. Thanks!</p>
  
  <p>I want to do something like this in the model, but I don't know how to get the user id.</p>
  
  <pre><code>   /**
       * Set updatedBy
       *
       * @ORM\PrePersist
       * @ORM\PreUpdate
       * @param integer $updatedBy
       */
      public function setUpdatedBy($updatedBy=null)
      {
          if (is_null($updatedBy)) {
              $updatedBy = $user-&gt;id;
          }
          $this-&gt;updatedBy = $updatedBy;
      }
  </code></pre>