Download the PHP package sherlockode/crud-bundle without Composer
On this page you can find all versions of the php package sherlockode/crud-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sherlockode/crud-bundle
More information about sherlockode/crud-bundle
Files in sherlockode/crud-bundle
Package crud-bundle
Short Description Bundle to generate CRUD
License MIT
Informations about the package crud-bundle
SherlockodeCrud Bundle
Overview
This bundle generate basic crud.
Installation
Install the bundle with composer:
Generate a basic grid view:
Customisation
You need custom action or custom field? You can easily define your own
You need the object instead of a property value in the grid?
You need to add filters on your grid?
You need to create a custom query for the grid?
- In this example, in the UserRepository, you need to have a function named
yourQueryBuilder
- The
yourQueryBuilder
function need to return aQueryBuilder
object
You need filters?
The bundle has basic filters
- String
- Boolean
- Float
- Money
- Date
- DateRange
- Entity
Entity filter need more configuration:
To add some filters:
You need custom filter?
If you need a filter that does not exist, create it !
Create your own filter class and your own filter type class, in this example MyCustomFilter
.
MyCustomFilter
need to implements FilterInterface
Now you need to set the template for your new filter:
You need to sort your grid?
You need to let the user choose the order?
You need to change the redirection a resource creation or edition?
By default, after a resource creation or edition, you will be redirected to the update action
You need a custom template for a route?
- In your templates project folder, be sure you have the
User
directory. - If you need a custom template only for the index action, name it
index.html.twig
, other routes will be rendered with the defaults templates
You only want to create the index route, not all of them?
You want to create all routes excepted delete?
You need to check permission before action?
Now make your own voter for each action
- index
- create
- edit
- delete
The attribute is prefixed by the resource_name
. In this example, it's user_index
You want to send some variable?
In this example, we send an icon to all paths.
If you want to do this only for a specific path:
You need to remove the delete confirmation page?
You need to add some information in the show view?
You need to change the translation domain?
You need to disable the translation domain?
If you need to be more specific, you can disable translation or set a custom for some grids
If you set a translation_domain for a grid, the value will replace the global one
You need to send data to the views?
In ResourceControllerDataEvent, you have several actions :
- ResourceControllerDataEvent::SHOW
- ResourceControllerDataEvent::CREATE
- ResourceControllerDataEvent::UPDATE
- ResourceControllerDataEvent::DELETE_CONFIRMATION
In ResourceController, in show, create, update and delete confirmation actions, an even is dispatched before the page is rendered.
If you need to send data to the view, you can create a listener.
In the view, the data variable will contain your data sent in the example above.
You need to prevent flush?
In ResourceControllerEvent, you have several actions :
- ResourceControllerEvent::BEFORE_CREATE
- ResourceControllerEvent::BEFORE_UPDATE
- ResourceControllerEvent::BEFORE_DELETE
In ResourceController, in create, update and delete actions, an even is dispatched before flush is performed.
If you need to cancel the flush, you can create a listener
All versions of crud-bundle with dependencies
knplabs/knp-paginator-bundle Version ^5.0 || ^6.0
symfony/form Version ^5.0 || ^6.0
symfony/framework-bundle Version ^5.0 || ^6.0
symfony/twig-bundle Version ^5.0 || ^6.0
twig/twig Version ^2.0 || ^3.0