Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you call <code>$this-&gt;get("your.service")</code> you are asking the dependency injection container to load that service. You are requesting that it loads one of your controllers which extends Symfony's controller class which extends <a href="http://api.symfony.com/2.0/Symfony/Component/DependencyInjection/ContainerAware.html">ContainerAware</a>. The error you are getting is because the loaded controller is likely trying to access a service like "request" using <code>$this-&gt;container-&gt;get("request")</code> but <code>$this-&gt;container</code> is not set.</p> <p>ContainerAware has a method <code>setContainer</code> which you can actually run when your service is setup by using the <code>calls:</code> argument in services.yml:</p> <pre><code>services: cj.businessbundle.purchase: class: CJ\BusinessBundle\Controller\PurchaseController calls: - [setContainer, [@service_container]] </code></pre> <p>Symfony2 does this for the loaded controller (PurchaseOrderController) but not if you just load a controller class yourself.</p> <p>It would be much better practice to extract the newAction (or the required logic) from PurchaseController as a service itself rather than setting the whole controller as a service. This way both Purchase and PurchaseOrder controllers can call the service to create a new purchase (or whatever newAction does) and you are not loading a whole controller everytime. Check out the <a href="https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Model/UserManager.php">FOS user bundle user manager</a> for a good example of a service or <a href="http://symfony.com/doc/2.1/book/service_container.html#what-is-a-service">http://symfony.com/doc/2.1/book/service_container.html#what-is-a-service</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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