Skip to content

Commit

Permalink
Move TemplateRegistryInterface::TYPE_* constants
Browse files Browse the repository at this point in the history
They have been moved to FieldDescriptionInterface since they are
the values of FieldDescriptionInterface::getType.
  • Loading branch information
franmomu committed Jan 8, 2021
1 parent b3f2de4 commit 4c2a846
Show file tree
Hide file tree
Showing 12 changed files with 328 additions and 148 deletions.
4 changes: 4 additions & 0 deletions UPGRADE-3.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Deprecated `getNbResults()` method in favor of `countResults()`.

Deprecated `$nbResults` property, `getNbResults()` and `setNbResults()` methods.

### Deprecated `Sonata\AdminBundle\Templating\TemplateRegistryInterface::TYPE_*` constants.

They have been moved to `Sonata\AdminBundle\Admin\FieldDescriptionInterface`.

UPGRADE FROM 3.83 to 3.84
=========================

Expand Down
42 changes: 21 additions & 21 deletions docs/reference/action_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ Here is an example::

// you may specify the field type directly as the
// second argument instead of in the options
->add('isVariation', TemplateRegistry::TYPE_BOOLEAN)
->add('isVariation', FieldDescriptionInterface::TYPE_BOOLEAN)

// if null, the type will be guessed
->add('enabled', null, [
'editable' => true
])

// editable association field
->add('status', TemplateRegistry::TYPE_CHOICE, [
->add('status', FieldDescriptionInterface::TYPE_CHOICE, [
'editable' => true,
'class' => 'Vendor\ExampleBundle\Entity\ExampleStatus',
'choices' => [
Expand All @@ -70,7 +70,7 @@ Here is an example::
])

// editable multiple field
->add('winner', TemplateRegistry::TYPE_CHOICE, [
->add('winner', FieldDescriptionInterface::TYPE_CHOICE, [
'editable' => true,
'multiple' => true,
'choices' => [
Expand All @@ -81,7 +81,7 @@ Here is an example::
])

// we can add options to the field depending on the type
->add('price', TemplateRegistry::TYPE_CURRENCY, [
->add('price', FieldDescriptionInterface::TYPE_CURRENCY, [
'currency' => $this->currencyDetector->getCurrency()->getLabel()
])

Expand Down Expand Up @@ -143,21 +143,21 @@ Options
Available types and associated options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

+--------------------------------------+---------------------+-----------------------------------------------------------------------+
| Type | Options | Description |
+======================================+=====================+=======================================================================+
| ``ListMapper::TYPE_ACTIONS`` | actions | List of available actions |
+ + + +
| | edit | Name of the action (``show``, ``edit``, ``history``, ``delete``, etc) |
+ + + +
| | link_parameters | Route parameters |
+--------------------------------------+---------------------+-----------------------------------------------------------------------+
| ``ListMapper::TYPE_BATCH`` | | Renders a checkbox |
+--------------------------------------+---------------------+-----------------------------------------------------------------------+
| ``ListMapper::TYPE_SELECT`` | | Renders a select box |
+--------------------------------------+---------------------+-----------------------------------------------------------------------+
| ``TemplateRegistry::TYPE_*`` | | See :doc:`Field Types <field_types>` |
+--------------------------------------+---------------------+-----------------------------------------------------------------------+
+---------------------------------------+---------------------+-----------------------------------------------------------------------+
| Type | Options | Description |
+=======================================+=====================+=======================================================================+
| ``ListMapper::TYPE_ACTIONS`` | actions | List of available actions |
+ + + +
| | edit | Name of the action (``show``, ``edit``, ``history``, ``delete``, etc) |
+ + + +
| | link_parameters | Route parameters |
+---------------------------------------+---------------------+-----------------------------------------------------------------------+
| ``ListMapper::TYPE_BATCH`` | | Renders a checkbox |
+---------------------------------------+---------------------+-----------------------------------------------------------------------+
| ``ListMapper::TYPE_SELECT`` | | Renders a select box |
+---------------------------------------+---------------------+-----------------------------------------------------------------------+
| ``FieldDescriptionInterface::TYPE_*`` | | See :doc:`Field Types <field_types>` |
+---------------------------------------+---------------------+-----------------------------------------------------------------------+

Symfony Data Transformers
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -614,10 +614,10 @@ Example::
'header_style' => 'width: 5%; text-align: center',
'row_align' => 'center'
])
->add('name', TemplateRegistry::TYPE_STRING, [
->add('name', FieldDescriptionInterface::TYPE_STRING, [
'header_style' => 'width: 35%'
])
->add('description', TemplateRegistry::TYPE_STRING, [
->add('description', FieldDescriptionInterface::TYPE_STRING, [
'header_style' => 'width: 35%',
'collapse' => true
])
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/action_show.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ The following is a working example of a ShowAction::
// The boolean option is actually very cool
// true shows a check mark and the 'yes' label
// false shows a check mark and the 'no' label
->add('dateCafe', TemplateRegistry::TYPE_BOOLEAN)
->add('datePub', TemplateRegistry::TYPE_BOOLEAN)
->add('dateClub', TemplateRegistry::TYPE_BOOLEAN)
->add('dateCafe', FieldDescriptionInterface::TYPE_BOOLEAN)
->add('datePub', FieldDescriptionInterface::TYPE_BOOLEAN)
->add('dateClub', FieldDescriptionInterface::TYPE_BOOLEAN)
;

}
Expand Down
Loading

0 comments on commit 4c2a846

Please sign in to comment.