title: How solve instance problem with Doctrine?
body: <p>I'm new learner of Symfony 4 and I'm looking for help. I've an Entity named "Player" and I want to generate a random confirmation number. </p>
  
  <p>For now, I'm using a variable <strong>$confirmNbr</strong> and I save the $confirm in my database with <strong>$participant->setConfirmationNumber($confirmNbr);</strong>.</p>
  
  <p>What I want it's create a function <strong>generateRandomNumber()</strong> in my Entity Player.php like this :</p>
  
  <pre><code>public function generateConfirmationNumber() : self 
  {
  
      $this-&gt;confirmationNumber = substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',6)),0,5);
  
      return $this;
  }
  </code></pre>
  
  <p>This is my Controller file </p>
  
  <pre><code>   /**
       * @Route("/", name="homepage")
       */
      public function new(Player $player, EntityManagerInterface $em, Request $request)
      {
          $participant = $this-&gt;playerrepo-&gt;findAll();
  
          $form = $this-&gt;createForm(PlayerFormType::class);
  
          $randomNbr = $player-&gt;generateConfirmationNumber();
  
  
  
          $form-&gt;handleRequest($request);
          if($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
              $data = $form-&gt;getData();
              $participant = new Player;
              $participant-&gt;setName($data['name']);
              $participant-&gt;setFirstname($data['firstname']);
              $participant-&gt;setEmail($data['email']);
              $participant-&gt;setConfirmationNumber($confirmNbr);
              $participant-&gt;setRegisterAt(new \DateTime);
  
              $em-&gt;persist($player);
              $em-&gt;flush();
  
              $this-&gt;addFlash('success', 'Player added!');
  
              return $this-&gt;redirectToRoute('homepage');
          }
  
          return $this-&gt;render('app/subscribe.html.twig', [
              'playerForm' =&gt; $form-&gt;createView(),
              'player'=&gt;$player,
          ]);
      }
  </code></pre>
  
  <p>And this is my error message :</p>
  
  <blockquote>
    <p>Unable to guess how to get a Doctrine instance from the request
    information for parameter "player".</p>
  </blockquote>
  
  <p>Can you help me please ?</p>