title: Symfony2 Form Validator - Comparing old and new values before flush
body: <p>I was wondering if there is a way to compare old and new values in a validator within an entity prior to a flush.</p>
  
  <p>I have a <code>Server</code> entity which renders to a form fine. The entity has a relationship to <code>status</code> (N->1) which, when the status is changed from <code>Unracked</code> to <code>Racked</code>, needs to check for SSH and FTP access to the server. If access is not achieved, the validator should fail.</p>
  
  <p>I have mapped a validator callback to the method <code>isServerValid()</code> within the <code>Server</code> entity as described here
  <a href="http://symfony.com/doc/current/reference/constraints/Callback.html">http://symfony.com/doc/current/reference/constraints/Callback.html</a>. I can obviously access the 'new' values via <code>$this-&gt;status</code>, but how can I get the original value?</p>
  
  <p>In pseudo code, something like this:</p>
  
  <pre><code>public function isAuthorValid(ExecutionContextInterface $context)
  {
      $original = ... ; // get old values
      if( $this-&gt;status !== $original-&gt;status &amp;&amp; $this-&gt;status === 'Racked' &amp;&amp; $original-&gt;status === 'Unracked' )
      {
          // check ftp and ssh connection
          // $context-&gt;addViolationAt('status', 'Unable to connect etc etc');
      }
  }
  </code></pre>
  
  <p>Thanks in advance!</p>