CRUDlex\Controller

class Controller

Default implementation of the ControllerInterface.

property filesystem

protected FilesystemInterface

Holds the filesystme.

property session

protected SessionInterface

Holds the session.

property translator

protected TranslatorInterface

Holds the translator.

property service

protected Service

Holds the service.

property twig

protected Twig_Environment

Holds the Twig instance.

modifyFilesAndSetFlashBag(Request $request, AbstractData $crudData, Entity $instance, $entity, $mode)

Postprocesses the entity after modification by handling the uploaded files and setting the flash.

Parameters:
  • $request (Request) – the current request
  • $crudData (AbstractData) – the data instance of the entity
  • $instance (Entity) – the entity
  • $entity (string) – the name of the entity
  • $mode (string) – whether to ‘edit’ or to ‘create’ the entity
Returns:

null|SymfonyComponentHttpFoundationRedirectResponse the HTTP response of this modification

setValidationFailedFlashes($optimisticLocking, $mode)

Sets the flashes of a failed entity modification.

Parameters:
  • $optimisticLocking (boolean) – whether the optimistic locking failed
  • $mode (string) – the modification mode, either ‘create’ or ‘edit’
modifyEntity(Request $request, AbstractData $crudData, Entity $instance, $entity, $edit)

Validates and saves the new or updated entity and returns the appropriate HTTP response.

Parameters:
  • $request (Request) – the current request
  • $crudData (AbstractData) – the data instance of the entity
  • $instance (Entity) – the entity
  • $entity (string) – the name of the entity
  • $edit (boolean) – whether to edit (true) or to create (false) the entity
Returns:

Response the HTTP response of this modification

getAfterDeleteRedirectParameters(Request $request, $entity, $redirectPage)

Gets the parameters for the redirection after deleting an entity.

Parameters:
  • $request (Request) – the current request
  • $entity (string) – the entity name
  • $redirectPage (string) – reference, where the page to redirect to will be stored
Returns:

array<string,string> the parameters of the redirection, entity and id

buildUpListFilter(Request $request, EntityDefinition $definition, $filter, $filterActive, $filterToUse, $filterOperators)

Builds up the parameters of the list page filters.

Parameters:
  • $request (Request) – the current request
  • $definition (EntityDefinition) – the current entity definition
  • $filter
  • $filterActive (boolean) – reference, will be true if at least one filter is active
  • $filterToUse (array) – reference, will hold a map of fields to integers (0 or 1) which boolean filters are active
  • $filterOperators (array) – reference, will hold a map of fields to operators for AbstractData::listEntries()
Returns:

array the raw filter query parameters

getNotFoundPage($error)

Generates the not found page.

Parameters:
  • $error (string) – the cause of the not found error
Returns:

Response the rendered not found page with the status code 404

__construct(Service $service, FilesystemInterface $filesystem, Twig_Environment $twig, SessionInterface $session, TranslatorInterface $translator)

Controller constructor.

Parameters:
  • $service (Service) – the CRUDlex service
  • $filesystem (FilesystemInterface) – the used filesystem
  • $twig (Twig_Environment) – the Twig environment
  • $session (SessionInterface) – the session service
  • $translator (TranslatorInterface) – the translation service
setLocaleAndCheckEntity(Request $request)

{@inheritdoc}

Parameters:
  • $request (Request) –
create(Request $request, $entity)

{@inheritdoc}

Parameters:
  • $request (Request) –
  • $entity
showList(Request $request, $entity)

{@inheritdoc}

Parameters:
  • $request (Request) –
  • $entity
show($entity, $id)

{@inheritdoc}

Parameters:
  • $entity
  • $id
edit(Request $request, $entity, $id)

{@inheritdoc}

Parameters:
  • $request (Request) –
  • $entity
  • $id
delete(Request $request, $entity, $id)

{@inheritdoc}

Parameters:
  • $request (Request) –
  • $entity
  • $id
renderFile($entity, $id, $field)

{@inheritdoc}

Parameters:
  • $entity
  • $id
  • $field
deleteFile($entity, $id, $field)

{@inheritdoc}

Parameters:
  • $entity
  • $id
  • $field
staticFile(Request $request)

{@inheritdoc}

Parameters:
  • $request (Request) –
setLocale(Request $request, $locale)

{@inheritdoc}

Parameters:
  • $request (Request) –
  • $locale