@@ -791,73 +791,6 @@ There are also special classes to make certain kinds of responses easier:
791791 ``Request `` and ``Response `` object in the
792792 :ref: `HttpFoundation component documentation <component-http-foundation-request >`.
793793
794- Creating Static Pages
795- ---------------------
796-
797- You can create a static page without even creating a controller (only a route
798- and template are needed). See cookbook article
799- :doc: `/cookbook/templating/render_without_controller `.
800-
801- .. index ::
802- single: Controller; Forwarding
803-
804- Forwarding to Another Controller
805- --------------------------------
806-
807- Though not very common, you can also forward to another controller
808- internally with the :method: `Symfony\\ Bundle\\ FrameworkBundle\\ Controller\\ Controller::forward `
809- method. Instead of redirecting the user's browser, this makes an "internal" sub-request
810- and calls the defined controller. The ``forward() `` method returns the ``Response ``
811- object that's returned from *that * controller::
812-
813- public function indexAction($name)
814- {
815- $response = $this->forward('AppBundle:Something:fancy', array(
816- 'name' => $name,
817- 'color' => 'green',
818- ));
819-
820- // ... further modify the response or return it directly
821-
822- return $response;
823- }
824-
825- The array passed to the method becomes the arguments for the resulting controller.
826- The target controller method might look something like this::
827-
828- public function fancyAction($name, $color)
829- {
830- // ... create and return a Response object
831- }
832-
833- Just like when creating a controller for a route, the order of the arguments of
834- ``fancyAction() `` doesn't matter: the matching is done by name.
835-
836- .. _checking-the-validity-of-a-csrf-token :
837-
838- Validating a CSRF Token
839- -----------------------
840-
841- Sometimes, you want to use CSRF protection in an action where you don't want to
842- use the Symfony Form component. If, for example, you're doing a DELETE action,
843- you can use the :method: `Symfony\\ Bundle\\ FrameworkBundle\\ Controller\\ Controller::isCsrfTokenValid `
844- method to check the CSRF token::
845-
846- if ($this->isCsrfTokenValid('token_id', $submittedToken)) {
847- // ... do something, like deleting an object
848- }
849-
850- .. versionadded :: 2.6
851- The ``isCsrfTokenValid() `` shortcut method was introduced in Symfony 2.6.
852- It is equivalent to executing the following code:
853-
854- .. code-block :: php
855-
856- use Symfony\Component\Security\Csrf\CsrfToken;
857-
858- $this->get('security.csrf.token_manager')
859- ->isTokenValid(new CsrfToken('token_id', 'TOKEN'));
860-
861794Final Thoughts
862795--------------
863796
@@ -880,5 +813,3 @@ Learn more from the Cookbook
880813
881814* :doc: `/cookbook/controller/error_pages `
882815* :doc: `/cookbook/controller/service `
883-
884- .. _`Controller class` : https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
0 commit comments