title: The best way to encode user password in Symfony 3?
body: <p>I know that I can use this encoder:</p>
  
  <pre><code>$encoder = $this-&gt;container-&gt;get('security.password_encoder');
  $encoded = $encoder-&gt;encodePassword($user, $plainPassword);
  </code></pre>
  
  <p>But when I should use it?
  I can encode password before calling setPassword() method. Or I can encode password in setPassword() method. Or maybe I should create a custom doctrine data type which will encode password before save to database? Or something else? Which variant is better?</p>