title: Check whether parameter exists or not in the request
body: <p>I have this function:</p>
  
  <pre><code>/**
   * @Secure(roles="IS_AUTHENTICATED_FULLY")
   * @Route("/chequearFabricanteDistribuidor", name="chequearFabricanteDistribuidor", condition="request.headers.get('X-Requested-With') == 'XMLHttpRequest'")
   * @Method("GET")
   */
  
  public function chequearFabricanteAction(Request $request)
  {
      $em       = $this-&gt;getDoctrine()-&gt;getManager();
      $entities = $em-&gt;getRepository('AppBundle:FabricanteDistribuidor')-&gt;findOneBy(
          array( 'nombre' =&gt; $request-&gt;query-&gt;get('fabricante')['nombre'] )
      );
  
      $response['valid'] = true;
  
      if ($entities) {
          $response['valid'] = false;
      }
  
      return new JsonResponse($response);
  }
  </code></pre>
  
  <p>The function needs to be called from two different forms and the only different is the request var that holds the value. In the first form is: <code>$request-&gt;query-&gt;get('fabricante')['nombre']</code> while in the second is <code>$request-&gt;query-&gt;get('distribuidor')['nombre']</code> so I'm asking if the right way to handle this could be:</p>
  
  <pre><code>if (isset($request-&gt;query-&gt;get('fabricante'))) 
  {
     $nombre = $request-&gt;query-&gt;get('fabricante')['nombre'];
  }
  else
  {
     $nombre = $request-&gt;query-&gt;get('distribuidor')['nombre'];
  }
  </code></pre>
  
  <p>Is this right? Exists a better one?</p>