PHP Class CRUDlex\ControllerProvider

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
Inheritance: implements Silex\Api\ControllerProviderInterface
Datei anzeigen Open project: philiplb/crudlex

Public Methods

Method Description
connect ( Silex\Application $app ) : SilexController\Collection Implements ControllerProviderInterface::connect() connecting this controller.
create ( Silex\Application $app, string $entity ) : Response The controller for the "create" action.
delete ( Silex\Application $app, string $entity, string $id ) : Response The controller for the "delete" action.
deleteFile ( Silex\Application $app, string $entity, string $id, string $field ) : Response The controller for the "delete file" action.
edit ( Silex\Application $app, string $entity, string $id ) : Response The controller for the "edit" action.
renderFile ( Silex\Application $app, string $entity, string $id, string $field ) : Response The controller for the "render file" action.
setLocale ( Request $request, Silex\Application $app, string $locale ) : Response The controller for setting the locale.
show ( Silex\Application $app, string $entity, string $id ) : Response The controller for the "show" action.
showList ( Request $request, Silex\Application $app, string $entity ) : Response The controller for the "show list" action.
staticFile ( Request $request, Silex\Application $app ) : Response The controller for serving static files.

Protected Methods

Method Description
buildUpListFilter ( Request $request, EntityDefinition $definition, &$filter, boolean &$filterActive, array &$filterToUse, array &$filterOperators ) Builds up the parameters of the list page filters.
getAfterDeleteRedirectParameters ( Request $request, string $entity, string &$redirectPage ) : string>\array Gets the parameters for the redirection after deleting an entity.
getNotFoundPage ( Silex\Application $app, string $error ) : Response Generates the not found page.
modifyEntity ( Silex\Application $app, AbstractData $crudData, Entity $instance, string $entity, boolean $edit ) : Response Validates and saves the new or updated entity and returns the appropriate HTTP response.
modifyFilesAndSetFlashBag ( Silex\Application $app, AbstractData $crudData, Entity $instance, string $entity, string $mode ) : null | RedirectResponse Postprocesses the entity after modification by handling the uploaded files and setting the flash.
setValidationFailedFlashes ( Silex\Application $app, boolean $optimisticLocking, string $mode ) Sets the flashes of a failed entity modification.
setupI18n ( Silex\Application $app ) Setups i18n.
setupRoutes ( Silex\Application $app ) : mixed Setups the routes.
setupTemplates ( Silex\Application $app ) Setups the templates.

Method Details

buildUpListFilter() protected method

Builds up the parameters of the list page filters.
protected buildUpListFilter ( Request $request, EntityDefinition $definition, &$filter, boolean &$filterActive, array &$filterToUse, array &$filterOperators )
$request Symfony\Component\HttpFoundation\Request the current application
$definition EntityDefinition the current entity definition
$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()

connect() public method

Implements ControllerProviderInterface::connect() connecting this controller.
public connect ( Silex\Application $app ) : SilexController\Collection
$app Silex\Application the Application instance of the Silex application
return SilexController\Collection this method is expected to return the used ControllerCollection instance

create() public method

The controller for the "create" action.
public create ( Silex\Application $app, string $entity ) : Response
$app Silex\Application the Silex application
$entity string the current entity
return Symfony\Component\HttpFoundation\Response the HTTP response of this action

delete() public method

The controller for the "delete" action.
public delete ( Silex\Application $app, string $entity, string $id ) : Response
$app Silex\Application the Silex application
$entity string the current entity
$id string the instance id to delete
return Symfony\Component\HttpFoundation\Response redirects to the entity list page or 404 on invalid input

deleteFile() public method

The controller for the "delete file" action.
public deleteFile ( Silex\Application $app, string $entity, string $id, string $field ) : Response
$app Silex\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
return Symfony\Component\HttpFoundation\Response redirects to the instance details page or 404 on invalid input

edit() public method

The controller for the "edit" action.
public edit ( Silex\Application $app, string $entity, string $id ) : Response
$app Silex\Application the Silex application
$entity string the current entity
$id string the instance id to edit
return Symfony\Component\HttpFoundation\Response the HTTP response of this action or 404 on invalid input

getAfterDeleteRedirectParameters() protected method

Gets the parameters for the redirection after deleting an entity.
protected getAfterDeleteRedirectParameters ( Request $request, string $entity, string &$redirectPage ) : string>\array
$request Symfony\Component\HttpFoundation\Request the current request
$entity string the entity name
$redirectPage string reference, where the page to redirect to will be stored
return string>\array

getNotFoundPage() protected method

Generates the not found page.
protected getNotFoundPage ( Silex\Application $app, string $error ) : Response
$app Silex\Application the Silex application
$error string the cause of the not found error
return Symfony\Component\HttpFoundation\Response the rendered not found page with the status code 404

modifyEntity() protected method

Validates and saves the new or updated entity and returns the appropriate HTTP response.
protected modifyEntity ( Silex\Application $app, AbstractData $crudData, Entity $instance, string $entity, boolean $edit ) : Response
$app Silex\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
return Symfony\Component\HttpFoundation\Response the HTTP response of this modification

modifyFilesAndSetFlashBag() protected method

Postprocesses the entity after modification by handling the uploaded files and setting the flash.
protected modifyFilesAndSetFlashBag ( Silex\Application $app, AbstractData $crudData, Entity $instance, string $entity, string $mode ) : null | RedirectResponse
$app Silex\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
return null | Symfony\Component\HttpFoundation\RedirectResponse the HTTP response of this modification

renderFile() public method

The controller for the "render file" action.
public renderFile ( Silex\Application $app, string $entity, string $id, string $field ) : Response
$app Silex\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
return Symfony\Component\HttpFoundation\Response the rendered file

setLocale() public method

The controller for setting the locale.
public setLocale ( Request $request, Silex\Application $app, string $locale ) : Response
$request Symfony\Component\HttpFoundation\Request the current request
$app Silex\Application the Silex application
$locale string the new locale
return Symfony\Component\HttpFoundation\Response redirects to the instance details page or 404 on invalid input

setValidationFailedFlashes() protected method

Sets the flashes of a failed entity modification.
protected setValidationFailedFlashes ( Silex\Application $app, boolean $optimisticLocking, string $mode )
$app Silex\Application the current application
$optimisticLocking boolean whether the optimistic locking failed
$mode string the modification mode, either 'create' or 'edit'

setupI18n() protected method

Setups i18n.
protected setupI18n ( Silex\Application $app )
$app Silex\Application the Application instance of the Silex application

setupRoutes() protected method

Setups the routes.
protected setupRoutes ( Silex\Application $app ) : mixed
$app Silex\Application the Application instance of the Silex application
return mixed the created controller factory

setupTemplates() protected method

Setups the templates.
protected setupTemplates ( Silex\Application $app )
$app Silex\Application the Application instance of the Silex application

show() public method

The controller for the "show" action.
public show ( Silex\Application $app, string $entity, string $id ) : Response
$app Silex\Application the Silex application
$entity string the current entity
$id string the instance id to show
return Symfony\Component\HttpFoundation\Response the HTTP response of this action or 404 on invalid input

showList() public method

The controller for the "show list" action.
public showList ( Request $request, Silex\Application $app, string $entity ) : Response
$request Symfony\Component\HttpFoundation\Request the current request
$app Silex\Application the Silex application
$entity string the current entity
return Symfony\Component\HttpFoundation\Response the HTTP response of this action or 404 on invalid input

staticFile() public method

The controller for serving static files.
public staticFile ( Request $request, Silex\Application $app ) : Response
$request Symfony\Component\HttpFoundation\Request the current request
$app Silex\Application the Silex application
return Symfony\Component\HttpFoundation\Response redirects to the instance details page or 404 on invalid input