class Controller extends ContainerAware
Controller is a simple implementation of a Controller.
It provides methods to common features needed in controllers.
Methods
|
setContainer(ContainerInterface $container = null)
Sets the Container. |
from ContainerAware | |
| string |
generateUrl(string $route, mixed $parameters = array(), Boolean $absolute = false)
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, integer $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. |
|
| NotFoundHttpException |
createNotFoundException(string $message = 'Not Found', Exception $previous = null)
Returns a NotFoundHttpException. |
|
| 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. |
|
| Boolean |
has(string $id)
Returns true if the service id is defined. |
|
| object |
get(string $id)
Gets a service by id. |
Details
in ContainerAware at line 37
public
setContainer(ContainerInterface $container = null)
Sets the Container.
at line 42
public string
generateUrl(string $route, mixed $parameters = array(), Boolean $absolute = false)
Generates a URL from the given parameters.
at line 56
public Response
forward(string $controller, array $path = array(), array $query = array())
Forwards the request to another controller.
at line 69
public RedirectResponse
redirect(string $url, integer $status = 302)
Returns a RedirectResponse to the given URL.
at line 82
public string
renderView(string $view, array $parameters = array())
Returns a rendered view.
at line 96
public Response
render(string $view, array $parameters = array(), Response $response = null)
Renders a view.
at line 113
public NotFoundHttpException
createNotFoundException(string $message = 'Not Found', Exception $previous = null)
Returns a NotFoundHttpException.
This will result in a 404 response code. Usage example:
throw $this->createNotFoundException('Page not found!');
at line 127
public Form
createForm(string|FormTypeInterface $type, mixed $data = null, array $options = array())
Creates and returns a Form instance from the type of the form.
at line 140
public FormBuilder
createFormBuilder(mixed $data = null, array $options = array())
Creates and returns a form builder instance
at line 150
public Request
getRequest()
Shortcut to return the request service.
at line 162
public Registry
getDoctrine()
Shortcut to return the Doctrine Registry service.
at line 178
public Boolean
has(string $id)
Returns true if the service id is defined.
at line 190
public object
get(string $id)
Gets a service by id.