You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Configuration file.protected$config = [];
protected$configArray = [];
// Entity.protected$entity;
// Entity Manager.protected$em;
// Query Builder.protected$queryBuilder;
// Form.protected$form;
// Allows you to configure options in the form an array must be setprotected$optionsForm = null;
Functions
indexAction(Request $request)
createQuery($repository)
exportCsvAction($format, Request $request = null, $arraySourceIterator = false)
filter($config, Request $request)
createAction(Request $request)
newAction()
queryEntity($id)
showAction($id)
editAction($id)
updateAction(Request $request, $id)
deleteAction(Request $request, $id)
getAutocompleteFormsMwsAction(Request $request, $options, $qb = null)
protected functionaddNewConfig(){} //The method is used to add new configprotectedfunctioncreateNewEntity(){$this->entity = new$this->configArray['entity']();} //The method is used to instantiate entity in newAction() and createAction(Request $request).protectedfunctionprePersistEntity(){} //The method is then used to validate form before flush entity in createAction(Request $request).protectedfunctionpreHandleRequestEntity(){}
protectedfunctionpreFormIsValid(){} //It is executed before validating the form in updateAction(Request $request, $id).protectedfunctionpreUpdateEntity(){}
protectedfunctionpreRemoveEntity(){}
protectedfunctionvalidateForm(){returntrue;} //Return true default. Execute before form->isValid() entity createAction(Request $request) and updateAction(Request $request, $id).protectedfunctionpreAddFilterConditions(){} // Execute before $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($this->filterForm, $this->queryBuilder); in filter(Request $request)
Override generate the path to redirect after saving the entity in createAction and updateAction:
/* Execute after success flush entity in createAction and updateAction */protectedfunctionurlSuccess()
{
if ($this->configArray['saveAndAdd']) {
$urlSuccess = $this->form->get('saveAndAdd')->isClicked()
? $this->generateUrl($this->configArray['new'])
: $this->generateUrl($this->configArray['show'], array('id' => $this->entity->getId()));
} else {
$urlSuccess = $this->generateUrl($this->configArray['show'], array('id' => $this->entity->getId()));
}
return$urlSuccess;
}