Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <a href="http://api.symfony.com/2.3/Symfony/Component/HttpKernel/HttpKernel.html" rel="nofollow"><code>Symfony\Component\HttpKernel\HttpKernel</code></a> object has no method <code>forward</code>. It's a method of <a href="http://api.symfony.com/2.3/Symfony/Bundle/FrameworkBundle/Controller/Controller.html#method_forward" rel="nofollow"><code>Symfony\Bundle\FrameworkBundle\Controller\Controller</code></a><br> This is why you are getting this error.<br> As a side note, you should not do any computation into your constructor. Better create a <code>process</code> method which is called immediatly after.</p> <p>Here's another way to do this:</p> <p><kbd><strong>services.yml</strong></kbd></p> <pre><code>services: my.service: class: MyProject\MyBundle\MyService scope: request arguments: - @http_kernel - @request calls: - [ handleForward, [] ] </code></pre> <p><strong>Note</strong>: <code>scope: request</code> is a mandatory parameter in order to give the <code>@request</code> service to your object.</p> <p><kbd><strong>MyProject\MyBundle\MyService</strong></kbd></p> <pre><code>use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpFoundation\Request; class MyService { protected $request; protected $kernel; public function __construct(HttpKernelInterface $kernel, Request $request) { $this-&gt;kernel = $kernel; $this-&gt;request = $request; } public function handleForward() { $controller = 'AcmeHelloBundle:Hello:fancy'; $path = array( 'name' =&gt; $name, 'color' =&gt; 'green', '_controller' =&gt; $controller ); $subRequest = $this-&gt;request-&gt;duplicate(array(), null, $path); $response = $this-&gt;kernel-&gt;handle($subRequest, HttpKernelInterface::SUB_REQUEST); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload