Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can put it in your bundle's Controller directory i.e <code>src/YourNamespace/YourBundleName/Controller/ControllerExtension.php</code>. Make sure you provide the appropriate namespace in that file:</p> <pre><code>namespace YourNamespace\YourBundleName\Controller; class ControllerExtension extends Symfony\Bundle\FrameworkBundle\Controller\Controller { ... </code></pre> <p>To use it, either create a route for it in <code>src/YourNamespace/YourBundlename/Resources/config/routing.yml</code></p> <p>or</p> <p>extend it:</p> <pre><code>namespace YourNamespace\YourBundleName\Controller; class OtherController extends ControllerExtension { ... </code></pre> <p>If what you are actually looking to do is override another bundle's controller, see the cookbook which describes <a href="http://symfony.com/doc/current/cookbook/bundles/inheritance.html" rel="nofollow">overriding controllers</a>.</p> <p><em>Edit</em>:</p> <p>As far as I know, there's no way to automatically make this controller somehow take effect. You can have each of your controllers extend it as I've indicated above.</p> <p>You might be able to <a href="http://symfony.com/doc/current/cookbook/service_container/event_listener.html" rel="nofollow">create an event listener</a> and use the <a href="http://api.symfony.com/2.2/Symfony/Component/HttpKernel/KernelEvents.html" rel="nofollow">response event</a> to somehow change the response if the format is json. But, I'm not sure how you would access the view data from the event listener.</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. This table or related slice is empty.
    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