This methods implements a simple, but usefull object create action.
/**
* @param Request $request
* @param array $templateVars
* @return Response|RedirectResponse
*/
public function crudCreateObject(Request $request, array $templateVars = array())
request
: contains the Request objectobject
: contains the objectform
: contains a form viewlistRoute
: contains the name of the list routecreateRoute
: contains the name of the create routeeditRoute
: contains the name of the edit routeviewRoute
: contains the name of the view routedeleteRoute
: contains the name of the delete routelistRole
: contains the name of the delete rolecreateRole
: contains the name of the delete roleeditRole
: contains the name of the delete roleviewRole
: contains the name of the delete roledeleteRole
: contains the name of the delete roleidentifier
: contains property name of the id of the object (id
in most cases)transPrefix
: contains the translation prefix (Controller::crudName()
)
This method defines a form type.
/**
* @param object $object
* @return FormTypeInterface
*/
protected function crudCreateFormType($object)
This method defines the create route name
/**
* @return string
*/
protected function crudCreateRoute()
This methods return if its allowed to call this object create action.
/**
* @return bool
*/
protected function crudCreateIsGranted()
This method defines the create role (for security check).
/**
* @return string
*/
protected function crudCreateRole()
This method creates a new object.
/**
* @return object
*/
protected function crudCreateFactory()
This method checks if the form is submitted, this allows form reloads with js for example.
/**
* @param FormInterface $form
* @return bool
*/
protected function crudCreateIsSubmitted(FormInterface $form)
This method returns the button name used by: is submitted
/**
* @return string|null
*/
protected function crudCreateButtonName()
This method defines the redirect url after create object
/**
* @param object $object
* @return string
*/
protected function crudCreateRedirectUrl($object)
This method defines the template path.
/**
* @return string
*/
protected function crudCreateTemplate()
This method allows to manipulate the object before persist
/**
* @param object $object
* @return void
*/
protected function crudCreatePrePersist($object)
This method allows to manipulate the object after flush
/**
* @param object $object
* @return void
*/
protected function crudCreatePostFlush($object)