CRUDlex\ControllerProvider

class ControllerProvider

This is the ControllerProvider offering all CRUD pages.

It offers this routes:

“/resource/static” serving static resources

“/{entity}/create” creation page of the entity

“/{entity}” list page of the entity

“/{entity}/{id}” details page of a single entity instance

“/{entity}/{id}/edit” edit page of a single entity instance

“/{entity}/{id}/delete” POST only deletion route for an entity instance

“/{entity}/{id}/{field}/file” renders a file field of an entity instance

“/{entity}/{id}/{field}/delete” POST only deletion of a file field of an entity instance

getNotFoundPage(Application $app, $error)

Generates the not found page.

Parameters:
  • $app (Application) – the Silex application
  • $error (string) – the cause of the not found error
Returns:

Response the rendered not found page with the status code 404

modifyFilesAndSetFlashBag(Application $app, AbstractData $crudData, Entity $instance, $entity, $mode)

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

Parameters:
  • $app (Application) – the current application
  • $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(Application $app, $optimisticLocking, $mode)

Sets the flashes of a failed entity modification.

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

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

Parameters:
  • $app (Application) – the current application
  • $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 application
  • $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()
setupTemplates(Application $app)

Setups the templates.

Parameters:
  • $app (Application) – the Application instance of the Silex application
setupRoutes(Application $app)

Setups the routes.

Parameters:
  • $app (Application) – the Application instance of the Silex application
Returns:

mixed the created controller factory

setupI18n(Application $app)

Setups i18n.

Parameters:
  • $app (Application) – the Application instance of the Silex application
connect(Application $app)

Implements ControllerProviderInterface::connect() connecting this controller.

Parameters:
  • $app (Application) – the Application instance of the Silex application
Returns:

SilexControllerCollection this method is expected to return the used ControllerCollection instance

create(Application $app, $entity)

The controller for the “create” action.

Parameters:
  • $app (Application) – the Silex application
  • $entity (string) – the current entity
Returns:

Response the HTTP response of this action

showList(Request $request, Application $app, $entity)

The controller for the “show list” action.

Parameters:
  • $request (Request) – the current request
  • $app (Application) – the Silex application
  • $entity (string) – the current entity
Returns:

Response the HTTP response of this action or 404 on invalid input

show(Application $app, $entity, $id)

The controller for the “show” action.

Parameters:
  • $app (Application) – the Silex application
  • $entity (string) – the current entity
  • $id (string) – the instance id to show
Returns:

Response the HTTP response of this action or 404 on invalid input

edit(Application $app, $entity, $id)

The controller for the “edit” action.

Parameters:
  • $app (Application) – the Silex application
  • $entity (string) – the current entity
  • $id (string) – the instance id to edit
Returns:

Response the HTTP response of this action or 404 on invalid input

delete(Application $app, $entity, $id)

The controller for the “delete” action.

Parameters:
  • $app (Application) – the Silex application
  • $entity (string) – the current entity
  • $id (string) – the instance id to delete
Returns:

Response redirects to the entity list page or 404 on invalid input

renderFile(Application $app, $entity, $id, $field)

The controller for the “render file” action.

Parameters:
  • $app (Application) – the Silex application
  • $entity (string) – the current entity
  • $id (string) – the instance id
  • $field (string) – the field of the file to render of the instance
Returns:

Response the rendered file

deleteFile(Application $app, $entity, $id, $field)

The controller for the “delete file” action.

Parameters:
  • $app (Application) – the Silex application
  • $entity (string) – the current entity
  • $id (string) – the instance id
  • $field (string) – the field of the file to delete of the instance
Returns:

Response redirects to the instance details page or 404 on invalid input

staticFile(Request $request, Application $app)

The controller for serving static files.

Parameters:
  • $request (Request) – the current request
  • $app (Application) – the Silex application
Returns:

Response redirects to the instance details page or 404 on invalid input

setLocale(Request $request, Application $app, $locale)

The controller for setting the locale.

Parameters:
  • $request (Request) – the current request
  • $app (Application) – the Silex application
  • $locale (string) – the new locale
Returns:

Response redirects to the instance details page or 404 on invalid input