Documentation

UserCrudController extends AbstractCrudController
in package

Provides shortcuts for HTTP-related features in controllers.

Table of Contents

Properties

$container  : ContainerInterface

Methods

autocomplete()  : JsonResponse
batchDelete()  : Response
configureActions()  : Actions
configureAssets()  : Assets
configureCrud()  : Crud
configureFields()  : array<string|int, FieldInterface>|array<string|int, string>
configureFilters()  : Filters
configureResponseParameters()  : KeyValueStore
Used to add/modify/remove parameters before passing them to the Twig template.
createEditForm()  : FormInterface
createEditFormBuilder()  : FormBuilderInterface
createEntity()  : mixed
createIndexQueryBuilder()  : QueryBuilder
createNewForm()  : FormInterface
createNewFormBuilder()  : FormBuilderInterface
delete()  : KeyValueStore|Response
deleteEntity()  : void
detail()  : KeyValueStore|Response
edit()  : KeyValueStore|Response
getEntityFqcn()  : string
getSubscribedServices()  : array<string|int, string>
Returns an array of service types required by such instances, optionally keyed by the service names used internally.
index()  : KeyValueStore|Response
new()  : KeyValueStore|Response
persistEntity()  : void
renderFilters()  : KeyValueStore
setContainer()  : ContainerInterface|null
updateEntity()  : void
addFlash()  : void
Adds a flash message to the current session for type.
addLink()  : void
Adds a Link HTTP header to the current response.
ajaxEdit()  : AfterCrudActionEvent
createAccessDeniedException()  : AccessDeniedException
Returns an AccessDeniedException.
createForm()  : FormInterface
Creates and returns a Form instance from the type of the form.
createFormBuilder()  : FormBuilderInterface
Creates and returns a form builder instance.
createNotFoundException()  : NotFoundHttpException
Returns a NotFoundHttpException.
denyAccessUnlessGranted()  : void
Throws an exception unless the attribute is granted against the current authentication token and optionally supplied subject.
file()  : BinaryFileResponse
Returns a BinaryFileResponse object with original or customized file name and disposition header.
forward()  : Response
Forwards the request to another controller.
generateUrl()  : string
Generates a URL from the given parameters.
getContext()  : AdminContext|null
getFieldAssets()  : AssetsDto
getParameter()  : array<string|int, mixed>|bool|string|int|float|UnitEnum|null
Gets a container parameter by its name.
getRedirectResponseAfterSave()  : RedirectResponse
getUser()  : UserInterface|null
Get a user from the Security Token Storage.
isCsrfTokenValid()  : bool
Checks the validity of a CSRF token.
isGranted()  : bool
Checks if the attribute is granted against the current authentication token and optionally supplied subject.
json()  : JsonResponse
Returns a JsonResponse that uses the serializer component if enabled, or json_encode.
processUploadedFiles()  : void
redirect()  : RedirectResponse
Returns a RedirectResponse to the given URL.
redirectToRoute()  : RedirectResponse
Returns a RedirectResponse to the given route with the given parameters.
render()  : Response
Renders a view.
renderForm()  : Response
Renders a view and sets the appropriate status code when a form is listed in parameters.
renderView()  : string
Returns a rendered view.
stream()  : StreamedResponse
Streams a view.

Properties

Methods

createEntity()

public createEntity(string $entityFqcn) : mixed
Parameters
$entityFqcn : string

getSubscribedServices()

Returns an array of service types required by such instances, optionally keyed by the service names used internally.

public static getSubscribedServices() : array<string|int, string>

For mandatory dependencies:

  • ['logger' => 'Psr\Log\LoggerInterface'] means the objects use the "logger" name internally to fetch a service which must implement Psr\Log\LoggerInterface.
  • ['loggers' => 'Psr\Log\LoggerInterface[]'] means the objects use the "loggers" name internally to fetch an iterable of Psr\Log\LoggerInterface instances.
  • ['Psr\Log\LoggerInterface'] is a shortcut for
  • ['Psr\Log\LoggerInterface' => 'Psr\Log\LoggerInterface']

otherwise:

  • ['logger' => '?Psr\Log\LoggerInterface'] denotes an optional dependency
  • ['loggers' => '?Psr\Log\LoggerInterface[]'] denotes an optional iterable dependency
  • ['?Psr\Log\LoggerInterface'] is a shortcut for
  • ['Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface']
Return values
array<string|int, string>

The required service types, optionally keyed by service names

addFlash()

Adds a flash message to the current session for type.

protected addFlash(string $type, mixed $message) : void
Parameters
$type : string
$message : mixed
Tags
throws
LogicException

createAccessDeniedException()

Returns an AccessDeniedException.

protected createAccessDeniedException([string $message = 'Access Denied.' ][, Throwable $previous = null ]) : AccessDeniedException

This will result in a 403 response code. Usage example:

throw $this->createAccessDeniedException('Unable to access this page!');

Parameters
$message : string = 'Access Denied.'
$previous : Throwable = null
Tags
throws
LogicException

If the Security component is not available

Return values
AccessDeniedException

createForm()

Creates and returns a Form instance from the type of the form.

protected createForm(string $type[, mixed $data = null ][, array<string|int, mixed> $options = [] ]) : FormInterface
Parameters
$type : string
$data : mixed = null
$options : array<string|int, mixed> = []
Return values
FormInterface

createFormBuilder()

Creates and returns a form builder instance.

protected createFormBuilder([mixed $data = null ][, array<string|int, mixed> $options = [] ]) : FormBuilderInterface
Parameters
$data : mixed = null
$options : array<string|int, mixed> = []
Return values
FormBuilderInterface

createNotFoundException()

Returns a NotFoundHttpException.

protected createNotFoundException([string $message = 'Not Found' ][, Throwable $previous = null ]) : NotFoundHttpException

This will result in a 404 response code. Usage example:

throw $this->createNotFoundException('Page not found!');

Parameters
$message : string = 'Not Found'
$previous : Throwable = null
Return values
NotFoundHttpException

denyAccessUnlessGranted()

Throws an exception unless the attribute is granted against the current authentication token and optionally supplied subject.

protected denyAccessUnlessGranted(mixed $attribute[, mixed $subject = null ][, string $message = 'Access Denied.' ]) : void
Parameters
$attribute : mixed
$subject : mixed = null
$message : string = 'Access Denied.'
Tags
throws
AccessDeniedException

file()

Returns a BinaryFileResponse object with original or customized file name and disposition header.

protected file(SplFileInfo|string $file[, string $fileName = null ][, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT ]) : BinaryFileResponse
Parameters
$file : SplFileInfo|string
$fileName : string = null
$disposition : string = ResponseHeaderBag::DISPOSITION_ATTACHMENT
Return values
BinaryFileResponse

forward()

Forwards the request to another controller.

protected forward(string $controller[, array<string|int, mixed> $path = [] ][, array<string|int, mixed> $query = [] ]) : Response
Parameters
$controller : string

The controller name (a string like Bundle\BlogBundle\Controller\PostController::indexAction)

$path : array<string|int, mixed> = []
$query : array<string|int, mixed> = []
Return values
Response

generateUrl()

Generates a URL from the given parameters.

protected generateUrl(string $route[, array<string|int, mixed> $parameters = [] ][, int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH ]) : string
Parameters
$route : string
$parameters : array<string|int, mixed> = []
$referenceType : int = UrlGeneratorInterface::ABSOLUTE_PATH
Tags
see
UrlGeneratorInterface
Return values
string

getParameter()

Gets a container parameter by its name.

protected getParameter(string $name) : array<string|int, mixed>|bool|string|int|float|UnitEnum|null
Parameters
$name : string
Return values
array<string|int, mixed>|bool|string|int|float|UnitEnum|null

getUser()

Get a user from the Security Token Storage.

protected getUser() : UserInterface|null
Tags
throws
LogicException

If SecurityBundle is not available

see
TokenInterface::getUser()
Return values
UserInterface|null

isCsrfTokenValid()

Checks the validity of a CSRF token.

protected isCsrfTokenValid(string $id, string|null $token) : bool
Parameters
$id : string

The id used when generating the token

$token : string|null

The actual token sent with the request that should be validated

Return values
bool

isGranted()

Checks if the attribute is granted against the current authentication token and optionally supplied subject.

protected isGranted(mixed $attribute[, mixed $subject = null ]) : bool
Parameters
$attribute : mixed
$subject : mixed = null
Tags
throws
LogicException
Return values
bool

json()

Returns a JsonResponse that uses the serializer component if enabled, or json_encode.

protected json(mixed $data[, int $status = 200 ][, array<string|int, mixed> $headers = [] ][, array<string|int, mixed> $context = [] ]) : JsonResponse
Parameters
$data : mixed
$status : int = 200
$headers : array<string|int, mixed> = []
$context : array<string|int, mixed> = []
Return values
JsonResponse

redirectToRoute()

Returns a RedirectResponse to the given route with the given parameters.

protected redirectToRoute(string $route[, array<string|int, mixed> $parameters = [] ][, int $status = 302 ]) : RedirectResponse
Parameters
$route : string
$parameters : array<string|int, mixed> = []
$status : int = 302
Return values
RedirectResponse

render()

Renders a view.

protected render(string $view[, array<string|int, mixed> $parameters = [] ][, Response $response = null ]) : Response
Parameters
$view : string
$parameters : array<string|int, mixed> = []
$response : Response = null
Return values
Response

renderForm()

Renders a view and sets the appropriate status code when a form is listed in parameters.

protected renderForm(string $view[, array<string|int, mixed> $parameters = [] ][, Response $response = null ]) : Response

If an invalid form is found in the list of parameters, a 422 status code is returned.

Parameters
$view : string
$parameters : array<string|int, mixed> = []
$response : Response = null
Return values
Response

renderView()

Returns a rendered view.

protected renderView(string $view[, array<string|int, mixed> $parameters = [] ]) : string
Parameters
$view : string
$parameters : array<string|int, mixed> = []
Return values
string

        
On this page

Search results