Controller
abstract class Controller implements ContainerAwareInterface (View source)
Base controller.
Properties
protected Container|null | $container |
Methods
Shortcut to return the request service.
Sets the Container associated with this Controller.
No description
Get mixed object from Dependency Injection container.
Return a service from container.
Returns true if the service is defined.
Alias for $this->container['securityAuthorizationChecker']
.
Alias for $this->container['securityTokenStorage']
.
Alias for $this->container['em']
.
No description
No description
Wrap $this->container['urlGenerator']->generate
Returns a RedirectResponse to the given URL.
No description
Validate a request against a given ROLE_* and throws an AccessDeniedException exception.
Custom route for redirecting routes with a trailing slash.
Make translation variable with the good localization.
Returns a rendered view.
Return a Response from a template string with its rendering assignation.
No description
No description
Forwards the request to another controller.
Returns a ResourceNotFoundException.
Returns an AccessDeniedException.
Creates and returns a Form instance from the type of the form.
Creates and returns a form builder instance.
Creates and returns a form builder instance.
Creates and returns an EntityListManager instance.
Create and return a ContactFormManager to build and send contact form by email.
Create and return a EmailManager to build and send emails.
Checks if the attributes are granted against the current authentication token and optionally supplied object.
Throws an exception unless the attributes are granted against the current authentication token and optionally supplied object.
Details
at line 74
Request
getRequest()
Shortcut to return the request service.
at line 85
ContainerAwareInterface
setContainer(Container $container)
Sets the Container associated with this Controller.
at line 94
Container
getContainer()
at line 108
mixed
getService(string|null $key = null)
deprecated
deprecated
Get mixed object from Dependency Injection container.
Alias for $this->container[$key]
at line 116
mixed
get(string $serviceName)
Return a service from container.
at line 124
bool
has(string $serviceName)
Returns true if the service is defined.
at line 134
AuthorizationChecker
getAuthorizationChecker()
Alias for $this->container['securityAuthorizationChecker']
.
at line 144
TokenStorageInterface
getTokenStorage()
Alias for $this->container['securityTokenStorage']
.
at line 154
EntityManager
em()
Alias for $this->container['em']
.
at line 162
Translator
getTranslator()
at line 170
Twig_Environment
getTwig()
at line 184
string
generateUrl(string|NodesSources $route, mixed $parameters = [], int $referenceType = Router::ABSOLUTE_PATH)
Wrap $this->container['urlGenerator']->generate
at line 197
RedirectResponse
redirect(string $url, integer $status = Response::HTTP_FOUND)
Returns a RedirectResponse to the given URL.
at line 205
static string
getCalledClass()
at line 222
validateAccessForRole(string $role)
Validate a request against a given ROLE_* and throws an AccessDeniedException exception.
at line 236
RedirectResponse
removeTrailingSlashAction(Request $request)
Custom route for redirecting routes with a trailing slash.
at line 255
protected Translation
bindLocaleFromRoute(Request $request, string $_locale = null)
Make translation variable with the good localization.
at line 296
string
renderView(string $view, array $parameters = [])
Returns a rendered view.
at line 313
Response
render(string $view, array $parameters = [], Response $response = null, string $namespace = "")
Return a Response from a template string with its rendering assignation.
at line 344
protected string
getNamespacedView(string $view, string $namespace = '')
at line 358
JsonResponse
renderJson(array $data = [], int $httpStatus = JsonResponse::HTTP_OK)
at line 372
protected Response
forward(string $controller, array $path = [], array $query = [])
Forwards the request to another controller.
at line 391
protected ResourceNotFoundException
createNotFoundException(string $message = 'Not Found', Exception $previous = null)
Returns a ResourceNotFoundException.
This will result in a 404 response code. Usage example:
throw $this->createNotFoundException('Page not found!');
at line 407
protected AccessDeniedException
createAccessDeniedException(string $message = 'Access Denied', Exception $previous = null)
Returns an AccessDeniedException.
This will result in a 403 response code. Usage example:
throw $this->createAccessDeniedException('Unable to access this page!');
at line 420
protected Form
createForm(string|FormTypeInterface $type, mixed $data = null, array $options = [])
Creates and returns a Form instance from the type of the form.
at line 433
protected FormBuilderInterface
createFormBuilder(mixed $data = null, array $options = [])
Creates and returns a form builder instance.
at line 446
protected FormBuilderInterface
createNamedFormBuilder($name = 'form', $data = null, array $options = [])
Creates and returns a form builder instance.
at line 463
EntityListManager
createEntityListManager(mixed $entity, array $criteria = [], array $ordering = [])
Creates and returns an EntityListManager instance.
at line 480
ContactFormManager
createContactFormManager()
Create and return a ContactFormManager to build and send contact form by email.
at line 490
EmailManager
createEmailManager()
Create and return a EmailManager to build and send emails.
at line 530
protected bool
isGranted(mixed $attributes, mixed $object = null)
Checks if the attributes are granted against the current authentication token and optionally supplied object.
at line 549
protected
denyAccessUnlessGranted(mixed $attributes, mixed $object = null, string $message = 'Access Denied.')
Throws an exception unless the attributes are granted against the current authentication token and optionally supplied object.