vox / crud-bundle
Installs: 1 080
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7
- doctrine/doctrine-bundle: ^1.9
- doctrine/orm: ^2.6
- jms/serializer-bundle: ^2.4
- symfony/framework-bundle: ~2.8|~3.0|~4.0
Requires (Dev)
- phpunit/phpunit: ^7.2
This package is auto-updated.
Last update: 2024-11-05 19:35:21 UTC
README
Configure Routes:
vox_crud: routes: firstStep: type: Presentation\Form\FirstStepType # the symfony form type to use class: Domain\Model\ProccessData # the object to be persisted, usualy a entity contextObject: Vox\CrudBundle\Form\CrudFormEvent # a context object for the events to be dispatched strategy: Infrastructure\CrudStrategy\FirstStepStrategy # the persistence strategy class, must implement the strategy interface operations: ['get', 'put'] # operations formTemplate: 'first-step/form.html.twig' # form twig template secondStep: type: Presentation\Form\FirstStepType class: Domain\Model\ProccessData contextObject: Vox\CrudBundle\Form\CrudFormEvent strategy: Infrastructure\CrudStrategy\FirstStepStrategy operations: ['get', 'put'] formTemplate: 'first-step/form.html.twig'
Custom Persistence Strategy
Register this class using the strategy option on your route configuration
namespace Infrastructure\CrudStrategy; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Vox\CrudBundle\Crud\Strategy\CrudPostFlushableInterface; use Vox\CrudBundle\Crud\Strategy\CrudStrategyInterface; class FirstStepStrategy implements CrudStrategyInterface, CrudPostFlushableInterface { public function persistDataObject(FormInterface $form) { //persist data using your database mechanism } public function createDataObjectForPost(Request $request) { //create the data object for the form when its a post route } public function createDataObjectForPut(Request $request) { //create the data object for the form when its a put route } public function createDataObjectForGet(Request $request) { //create the data object for the form when its a get route } public function postFlush($object) { //do something after the flushing of doctrine or your database mechanism } }
Events
This bundle exposes some events to help manipulate the forms