This document describes all the significant changes made between 1.0 and 1.1 branches. It also covers transition to 2.0 branch, since 1.1 and 2.0 are backwards compatibile.
The major change in admin-bundle's architecture is splitting one monolithic
FSi\Bundle\AdminBundle\Admin\CRUD\CRUDInterface
into a couple of smaller, more
specialized interfaces of admin elements:
FSi\Bundle\AdminBundle\Admin\CRUD\ListElement
- creates list of items using fsi/datasource and fsi/datagridFSi\Bundle\AdminBundle\Admin\CRUD\FormElement
- creates form for a single itemFSi\Bundle\AdminBundle\Admin\CRUD\BatchElement
- performs some simple action on a single item
These interfaces have been combined again into
FSi\Bundle\AdminBundle\Admin\CRUD\CRUDElement
which behaves exactly as the old one
FSi\Bundle\AdminBundle\Admin\CRUD\CRUDInterface
to ease the upgrade process.
This element was created to allow performing of repeatable operations on items selected by user on the list. Please refer to the full description of how to use such an admin element. The first general use case of such an operation is deleting selected items, which is implemented as a batch admin element. Other examples are activating/deactivating selected users, turning on/off visibility of selected articles, moving selected articles to the archive, etc. New batch elements can be simply linked to the list element using batch column options in datagrid.
Brand new FSi\Bundle\AdminBundle\Admin\Display\Element
has been introduced and it
creates a specialized display object for a single item. This object is used to show selected properties of an item
(entity) in a standardized way.
Thanks to the introducing of smaller admin elements it's now possible to build more complicated administration interfaces with several different forms and/or displays for one type of item/entity. These different forms and/or displays can be i.e. separately secured for different user roles.
Creation and editing of an item was previously handled by two different actions and their templates, but since one admin list element can be linked to more than one form, such a separation is no longer necessary. The "add" button can simply link to different form element than "edit" button.
There is a new and easier way of registering admin elements by marking them with @Admin\Element
annotation. If
you wish to set custom options for admin element using this method you have to do this in setDefaultOptions()
through $resolver->setDefaults()
.
Deleting of selected items no longer display intermediate action with confirmation form. Such a confirmation can be added by attaching some JS to the "Ok" button which performs selected batch action.
Method getName()
was removed from all admin elements. Previously it was used only during building of the admin menu.
Now admin menu is built using additional configuration file as described here.
The following options were removed from FSi\Bundle\AdminBundle\Admin\CRUD\AbstractCRUD
menu
- removed from all admin elements in favour of new method of menu building methodallow_edit
- removed because there is no longer any specific "edit" actioncrud_list_title
- removed in favour ofheader
block in list templatecrud_create_title
- removed in favour ofheader
block in form templatecrud_edit_title
- removed in favour ofheader
block in form templatetemplate_crud_delete
- removed because delete action has no longer any intermediate confirmation action
template_list
- template for the list action, its default value is taken from deprecatedtemplate_crud_list
optiontemplate_form
- template for the form action, its default value is taken from deprecatedtemplate_crud_edit
option
template_crud_list
- will be removed in favor oftemplate_list
template_crud_edit
- will be removed in favor oftemplate_form
template_crud_create
- will be removed in favor oftemplate_form
Important! - if you are using both template_crud_create
and template_crud_edit
, please note that they have
to have the same value since there are no longer different contexts handling creation and update of an item.
Resources/views/CRUD/List/*.html.twig
- these were the rarely used partials included byResources/views/CRUD/list.html.twig
. Since there are gone, overwriting them inapp/Resources
has no longer any effect andResources/views/CRUD/list.html.twig
should be overwritten instead.Resources/views/CRUD/delete.html.twig
- it is no longer needed since there is no longer any confirmation step while deleting selected items.
Resources/views/CRUD/list.html.twig
- it extendsResources/views/List/list.html.twig
. Since batch actions are added thought datagrid batch column's options, there are no longerbatch_action
andbatch_form
blocks to overwrite. There is a new blockbatch_actions
containing the whole batch action selection form.Resources/views/CRUD/edit.html.twig
- was removed in favour ofResources/views/CRUD/form.html.twig
and overwriting it inapp/Resources
has no longer any effect.Resources/views/CRUD/create.html.twig
- was removed in favour ofResources/views/CRUD/form.html.twig
and overwriting it inapp/Resources
has no longer any effect.Resources/views/Form/form_div_layout.html.twig
- was renamed toResources/views/Form/form_theme.html.twig
.
All contexts and handlers classes which previously existed in FSi\Bundle\AdminBundle\Doctrine\Context
namespace have
been removed in favour of new generic (non doctrine-dependent) contexts and handlers in
FSi\Bundle\AdminBundle\Admin\CRUD\Context
namespace.
Since contexts are rebuild from scratch the naming of events has been also changed.
1.0.* | ~1.1 | ||
---|---|---|---|
constant | name | constant | name |
CRUDEvents::CRUD_LIST_CONTEXT_POST_CREATE | 'admin.crud.list.context.post_create' |
- | - |
CRUDEvents::CRUD_LIST_DATASOURCE_REQUEST_PRE_BIND | 'admin.crud.list.datasource.request.pre_bind' |
ListEvents::LIST_DATASOURCE_REQUEST_PRE_BIND | 'admin.list.datasource.request.pre_bind' |
CRUDEvents::CRUD_LIST_DATASOURCE_REQUEST_POST_BIND | 'admin.crud.list.datasource.request.post_bind' |
ListEvents::LIST_DATASOURCE_REQUEST_POST_BIND | 'admin.list.datasource.request.post_bind' |
CRUDEvents::CRUD_LIST_DATAGRID_DATA_PRE_BIND | 'admin.crud.list.datagrid.data.pre_bind' |
ListEvents::LIST_DATAGRID_DATA_PRE_BIND | 'admin.list.datagrid.data.pre_bind' |
CRUDEvents::CRUD_LIST_DATAGRID_DATA_POST_BIND | 'admin.crud.list.datagrid.data.post_bind' |
ListEvents::LIST_DATAGRID_DATA_POST_BIND | 'admin.list.datagrid.data.post_bind' |
CRUDEvents::CRUD_LIST_DATAGRID_REQUEST_PRE_BIND | 'admin.crud.list.datagrid.request.pre_bind' |
ListEvents::LIST_DATAGRID_REQUEST_PRE_BIND | 'admin.list.datagrid.request.pre_bind' |
CRUDEvents::CRUD_LIST_DATAGRID_REQUEST_POST_BIND | 'admin.crud.list.datagrid.request.post_bind' |
ListEvents::LIST_DATAGRID_REQUEST_POST_BIND | 'admin.list.datagrid.request.post_bind' |
CRUDEvents::CRUD_LIST_RESPONSE_PRE_RENDER | 'admin.crud.list.response.pre_render' |
ListEvents::LIST_RESPONSE_PRE_RENDER | 'admin.list.response.pre_render' |
CRUDEvents::CRUD_CREATE_CONTEXT_POST_CREATE CRUDEvents::CRUD_EDIT_CONTEXT_POST_CREATE |
'admin.crud.create.context.post_create' 'admin.crud.edit.context.post_create' |
- | - |
CRUDEvents::CRUD_CREATE_FORM_REQUEST_PRE_SUBMIT CRUDEvents::CRUD_EDIT_FORM_REQUEST_PRE_SUBMIT |
admin.crud.create.form.request.pre_submit' 'admin.crud.edit.form.request.pre_submit' |
FormEvents::FORM_REQUEST_PRE_SUBMIT | 'admin.form.request.pre_submit' |
CRUDEvents::CRUD_CREATE_FORM_REQUEST_POST_SUBMIT CRUDEvents::CRUD_EDIT_FORM_REQUEST_POST_SUBMIT |
'admin.crud.create.form.request.post_submit' 'admin.crud.edit.form.request.post_submit' |
FormEvents::FORM_REQUEST_POST_SUBMIT | 'admin.form.request.post_submit' |
CRUDEvents::CRUD_CREATE_ENTITY_PRE_SAVE CRUDEvents::CRUD_EDIT_ENTITY_PRE_SAVE |
'admin.crud.create.entity.pre_save' 'admin.crud.edit.entity.pre_save' |
FormEvents::FORM_DATA_PRE_SAVE | 'admin.form.data.pre_save' |
CRUDEvents::CRUD_CREATE_ENTITY_POST_SAVE CRUDEvents::CRUD_EDIT_ENTITY_POST_SAVE |
'admin.crud.create.entity.post_save' 'admin.crud.edit.entity.post_save' |
FormEvents::FORM_DATA_POST_SAVE | 'admin.form.data.post_save' |
CRUDEvents::CRUD_CREATE_RESPONSE_PRE_RENDER CRUDEvents::CRUD_EDIT_RESPONSE_PRE_RENDER |
'admin.crud.create.response.pre_render' 'admin.crud.edit.response.pre_render' |
FormEvents::FORM_RESPONSE_PRE_RENDER | 'admin.form.response.pre_render' |
CRUDEvents::CRUD_DELETE_CONTEXT_POST_CREATE | 'admin.crud.delete.context.post_create' |
- | - |
CRUDEvents::CRUD_DELETE_FORM_PRE_SUBMIT | 'admin.crud.delete.form.pre_submit' |
BatchEvents::BATCH_REQUEST_PRE_SUBMIT | 'admin.batch.request.pre_submit' |
CRUDEvents::CRUD_DELETE_FORM_POST_SUBMIT | 'admin.crud.delete.form.post_submit' |
BatchEvents::BATCH_REQUEST_POST_SUBMIT | 'admin.batch.request.post_submit' |
CRUDEvents::CRUD_DELETE_ENTITIES_PRE_DELETE | 'admin.crud.delete.entities.pre_delete' |
BatchEvents::BATCH_OBJECTS_PRE_APPLY | 'admin.batch.objects.pre_apply' |
CRUDEvents::CRUD_DELETE_ENTITIES_POST_DELETE | 'admin.crud.delete.entities.post_delete' |
BatchEvents::BATCH_OBJECTS_POST_APPLY | 'admin.batch.objects.post_apply' |
Additional notes:
- since there are no different events when creating and editing of an item you should distinguish these two situations
by examining
$event->getForm()->getData()
in your event handler. - since all batch events are common for all batch actions (i.e. not only delete), you should identify the action being
performed by examining the class of
$event->getElement()
in your event handler.
Admin menu is read from %kernel.project_dir%/config/admin_menu.yml by default but the path to menu file can be changed by
setting fsi_admin.menu_config_path
configuration option.
If you want your admin to be multilingual you must set the array of supported locales in fsi_admin.locales
configuration option.
The following bundle configuration options have been removed due to removal of their underlying functionality:
fsi_admin.display_language_switch
fsi_admin.templates.crud_create
fsi_admin.templates.crud_edit
was renamed tofsi_admin.templates.crud_form
fsi_admin.templates.crud_delete
fsi_admin.templates.edit_form_theme
fsi_admin.templates.create_form_theme
fsi_admin.templates.delete_form_theme
fsi_admin.templates.resource_form_theme
The following old routes have been marked deprecated and redirected to the new routes
fsi_admin_crud_list
->fsi_admin_list
fsi_admin_crud_create
->fsi_admin_form
fsi_admin_crud_edit
->fsi_admin_form
fsi_admin_crud_delete
->fsi_admin_batch