title: Symfony validation callback
body: <p>I'm trying to validate my entity via static callback.</p>
  
  <p>I was able to make it work following the <a href="https://symfony.com/doc/current/reference/constraints/Callback.html" rel="nofollow noreferrer">Symfony guide</a> but something isn't  clear to me.</p>
  
  <pre><code>public static function validate($object, ExecutionContextInterface $context, $payload)
  {
      // somehow you have an array of "fake names"
      $fakeNames = array(/* ... */);
  
      // check if the name is actually a fake name
      if (in_array($object-&gt;getFirstName(), $fakeNames)) {
          $context-&gt;buildViolation('This name sounds totally fake!')
              -&gt;atPath('firstName')
              -&gt;addViolation()
          ;
      }
  }
  </code></pre>
  
  <p>It works fine when I populate my <code>$fakeNames</code> array but what if I want to make it "dynamic"? Let's say I want to pick that array from the parameters or from the database or wherever.
  How am I supposed to pass stuff (eg. the container or entityManager) to this class from the moment that the constructor doesn't work and it has to be necessarily static?</p>
  
  <p>Of course my approach may be completely wrong but I'm just using the symfony example and few other similar issues found on the internet that I'm trying to adapt to my case.</p>