title: How to encode the password for an arbitrary entity in Symfony?
body: <p>I'm creating organizations table in mysql.</p>
  
  <p>The entity is called <code>Organisation</code> and it has a <code>password</code> field.</p>
  
  <p>When I try to use <code>UserPasswordEncoderInterface</code> it expects the <code>user</code> entity, so this doesn't work. I tried using <code>PasswordEncoderInterface</code>, but it says that the service is not exist. What can be done here ? </p>
  
  <p>This is my code:</p>
  
  <pre><code>   public function register(Request $request, EntityManagerInterface $entityManager, PasswordEncoderInterface $encoder)
      {
          $organisation = new Organisation();
  
          $form = $this-&gt;createForm(OrganisationRegisterType::class, $organisation);
  
          $form-&gt;handleRequest($request);
  
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
              $plainPassword = $form-&gt;getData()-&gt;getPassword();
              $encoded = $encoder-&gt;encodePassword($plainPassword, null);
              $organisation-&gt;setPassword($encoded);
  
              $entityManager = $this-&gt;getDoctrine()-&gt;getManager();
              $entityManager-&gt;persist($organisation);
              $entityManager-&gt;flush();
  
              $this-&gt;addFlash(
                  'success',
                  'Organizacija sukurta sėkmingai. Nurodytu el. paštu buvo išsiųsta prisijungimo informacija'
              );
          }
  </code></pre>
  
  <p>This is the error I get:</p>
  
  <blockquote>
    <p>Cannot autowire argument $encoder of "App\Controller\OrganisationController::register()": it references interface "Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface" but no such service exists. Did you create a class that implements this interface?`</p>
  </blockquote>