This document describes the process of Symfony's Easy Admin Bundle, to process the given YAML configuration, with registered ConfigPass classes.
Those ConfigPasses are collections of private methods, which have e.g. action names hardcoded, so you can't reuse the "config auto-magic" for your new actions.
Make ConfigPasses more accessible and reusable. Make it easier to e.g. provide new actions, which also inherit from "form" config and get normalized with default values.
The config passes are registered and get executed in the following order:
Each step iterates over configured entities
.
- normalizeEntityConfig:
- Apply label or label is not set, apply the entity name as label
- normalizeViewConfig:
- Applies
list.dql_filter
tosearch.dql_filter
or set both to null - Merges views
['edit', 'form', 'list', 'new', 'search', 'show']
(hardcoded!) with default config
- Applies
- normalizePropertyConfig:
- Process
fields
in views['form', 'edit', 'list', 'new', 'search', 'show']
(hardcoded!)- check if field is string or array
- if is array check if property is set, throws exception if not
- if is string create array with property set with string value
- check if
type
in field is image (setbase_path
toimage_base_path
then) - check if
type
in field is file (setbase_path
tofile_base_path
then) - set field name to
property
, or ifproperty
is null, apply_easyadmin_form_design_element_
with iterator as field name
- check if field is string or array
- Process
- normalizeFormDesignConfig:
- Process
fields
in views['form', 'edit', 'new']
(hardcoded!)- check if field is "formDesignElement" (property=null, type set)
- check for tab first, later also for group, divider and section
- Process
- normalizeActionConfig:
- First, processes the views
['edit', 'list', 'new', 'show', 'form']
(hardcoded!) and setactions
in each view to empty array, if not given. - Then iterates over
entities
and does the same there (inactions
). Ifactions
is set, but no array, an exception is thrown
- First, processes the views
- normalizeBatchActionConfig:
- Initializes
list.batch_actions
(empty array) if not set - Does the same for
batch_actions
in each entity - Throws exception if
batch_actions
is given, but no array
- Initializes
- normalizeFormConfig:
- Merges
form
withnew
andedit
- During merge, fields with prefixed
'-'
get removed
- During merge, fields with prefixed
- Merges
- normalizeControllerConfig:
- Checks for given controller (in each entity)
- normalizeTranslationConfig:
- Set
translation_domain
for each entity to roottranslation_domain
config value if not set.
- Set
- processRtlLanguages:
- When root
locale
is one of these['ar', 'fa', 'he']
, setdesign.rtl
to true
- When root
- builds menu defined in
design.menu
- processDisabledActions
- applies root
disabled_actions
to each entity, if not set
- applies root
- normalizeActionsConfig
- for hardcoded! views
['edit', 'list', 'new', 'show']
- set label if empty
- applies default values to each config
- first all this apply to configured
actions
on root level. Then it's applied toactions
of each entity.
- for hardcoded! views
- normalizeBatchActionsConfig
- normalizes
list.batch_actions
config- set btn-danger css class when deleted is given
- does the same for each entity (
entities.example.list.batch_actions
)
- normalizes
- resolveActionInheritance
- for hardcoded! views
['edit', 'list', 'new', 'show']
- merges
actions
in each entity with defined default, backend and entity actions - removes actions configured with
'-'
- reorders actions
- for hardcoded! views
- resolveBatchActionInheritance
- same like resolveActionInheritance
- just for
list.batch_actions
in each entity
- processActionsConfig
- for hardcoded! views
['edit', 'list', 'new', 'show']
- checks each action in each entity, if is valid method name and apply css_class "action-example"
- for hardcoded! views
- processBatchActionsConfig
- resolves
list.batch_actions
in each entity - checks if type is "method" (which is required for batch actions)
- and check for valid method name
- resolves
- set
properties
based on givenentities
and Doctrine metadata. - also set
primary_key_field_name
- processMetadataConfig
- guesses types and default options in each item in
entities
based on itsproperties
- guesses types and default options in each item in
- processFieldConfig
- just for actions
['edit', 'list', 'new', 'search', 'show']
- check for
virtual
properties - set
dataType
to type (for actions['list', 'search', 'show']
) - set
fieldType
to$originalFieldConfig['type']
or$normalizedConfig['fieldType']
(for actions['list', 'search', 'show']
) - set
fieldType
to textarea when still empty - set
type_options
(merges doctrine metadata with own configuration) - set
format
if empty (\EasyCorp\Bundle\EasyAdminBundle\Configuration\PropertyConfigPass::getFieldFormat
) - in list action, when dataType is "boolean", change dataType to "toggle", if it wasn't configured in original field config
- just for actions
- all limited to actions
['edit', 'list', 'new', 'search', 'show']
- processViewConfig
- processDefaultFieldsConfig
- processFieldConfig
- processPageTitleConfig
- processMaxResultsConfig (only in
['list', 'search', 'show']
actions) - processSortingConfig (only in
['list', 'search']
actions)
- processEntityTemplates
- resolve (first) template from configured paths (
entities.example.templates
->design.templates
-> default) - for
['list', 'show']
actions also apply custom template for each field (if given)
- resolve (first) template from configured paths (
- processDefaultTemplates
- resolve (first) template from
design.templates
and default paths
- resolve (first) template from
- processFieldTemplates
- just in
['list', 'show']
actions - assignes templates to each field (e.g. hides primary key field by using template "field_id")
- just in
- processDefaultEntity
- set
default_entity_name
to first entity in yaml config
- set
- processDefaultMenuItem
- set
default_menu_item
to first item withdefault: true
- set
- processDefaultHomepage
- set
homepage
to default menu item, if given - otherwise route to list action of first configured entity in yaml
- set