class Controller extends ContainerAware
Controller is a simple implementation of a Controller.
It provides methods to common features needed in controllers.
setContainer(ContainerInterface $container = null) Sets the container. | from ContainerAware | |
string | generateUrl(string $route, mixed $parameters = array(), int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) Generates a URL from the given parameters. | |
Response | forward(string $controller, array $path = array(), array $query = array()) Forwards the request to another controller. | |
RedirectResponse | redirect(string $url, int $status = 302) Returns a RedirectResponse to the given URL. | |
string | renderView(string $view, array $parameters = array()) Returns a rendered view. | |
Response | render(string $view, array $parameters = array(), Response $response = null) Renders a view. | |
StreamedResponse | stream(string $view, array $parameters = array(), StreamedResponse $response = null) Streams a view. | |
NotFoundHttpException | createNotFoundException(string $message = 'Not Found', Exception $previous = null) Returns a NotFoundHttpException. | |
AccessDeniedException | createAccessDeniedException(string $message = 'Access Denied.', Exception $previous = null) Returns an AccessDeniedException. | |
Form | createForm(string|FormTypeInterface $type, mixed $data = null, array $options = array()) Creates and returns a Form instance from the type of the form. | |
FormBuilder | createFormBuilder(mixed $data = null, array $options = array()) Creates and returns a form builder instance. | |
Request | getRequest() Shortcut to return the request service. | |
Registry | getDoctrine() Shortcut to return the Doctrine Registry service. | |
mixed | getUser() Get a user from the Security Token Storage. | |
bool | has(string $id) Returns true if the service id is defined. | |
object | get(string $id) Gets a container service by its id. |
Sets the container.
Generates a URL from the given parameters.
Forwards the request to another controller.
Returns a RedirectResponse to the given URL.
Returns a rendered view.
Renders a view.
Streams a view.
Returns a NotFoundHttpException.
This will result in a 404 response code. Usage example:
throw $this->createNotFoundException('Page not found!');
Returns an AccessDeniedException.
This will result in a 403 response code. Usage example:
throw $this->createAccessDeniedException('Unable to access this page!');
Creates and returns a Form instance from the type of the form.
Creates and returns a form builder instance.
Shortcut to return the request service.
Shortcut to return the Doctrine Registry service.
Get a user from the Security Token Storage.
Returns true if the service id is defined.
Gets a container service by its id.
© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.8/Symfony/Bundle/FrameworkBundle/Controller/Controller.html