Skip to content

Commit 8bd765d

Browse files
committed
[TASK] Deprecate InfoboxViewHelper STATE_* constants
Resolves: TYPO3-Documentation/Changelog-To-Doc#1355 Releases: main
1 parent 47eeffb commit 8bd765d

File tree

7 files changed

+73
-58
lines changed

7 files changed

+73
-58
lines changed

Documentation/Global/Be/Infobox.rst

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@ Be.infobox ViewHelper `<f:be.infobox>`
2424
Severity states of the Be.infobox ViewHelper
2525
============================================
2626

27+
.. deprecated:: 14.0
28+
The public constants in :php-short:`\TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper`
29+
for defining the state/severity of an infobox have been deprecated. Use
30+
the enum :php:`\TYPO3\CMS\Core\Type\ContextualFeedbackSeverity` instead.
31+
2732
The Infobox provides different context-sensitive states that
2833
can be used to provide an additional visual feedback to the
29-
3034
user to underline the meaning of the information.
3135

32-
Possible values are in range from ``-2`` to ``2``. Please choose a
33-
meaningful value from the following list.
36+
The `state` property allows enums of type :php:`\TYPO3\CMS\Core\Type\ContextualFeedbackSeverity`
37+
and integer values between `-2` and `+2` for backward compatibility.
3438

3539
.. tabs::
3640

@@ -41,32 +45,32 @@ meaningful value from the following list.
4145

4246
A demonstration of all possible states
4347

44-
.. group-tab:: Numeral values
48+
.. group-tab:: Enum values
4549

46-
``-2``
50+
`ContextualFeedbackSeverity::NOTICE` (-2)
4751
Notices (Default)
48-
``-1``
52+
`ContextualFeedbackSeverity::INFO` (-1)
4953
Information
50-
``0``
54+
`ContextualFeedbackSeverity::OK` (0)
5155
Positive feedback
52-
``1``
56+
`ContextualFeedbackSeverity::WARNING` (1)
5357
Warnings
54-
``2``
58+
`ContextualFeedbackSeverity::ERROR` (2)
5559
Error
5660

5761
.. group-tab:: Code example
5862

5963
It is considered best practice to use the states from
60-
:php:`\TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper` together with the
64+
:php:`\TYPO3\CMS\Core\Type\ContextualFeedbackSeverity` enum together with the
6165
`Constant ViewHelper <f:constant> <https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-constant>`_:
6266

6367
.. literalinclude:: _Infobox/_States.html
6468
:caption: EXT:my_extension/Resources/Private/Backend/Templates/MyModule.html
6569

6670
.. _typo3-fluid-be-infobox-example:
6771

68-
Examples
69-
========
72+
Examples of Be.infobox ViewHelper usage
73+
=======================================
7074

7175
Info box of level notice with a static title and a static text:
7276

@@ -77,29 +81,14 @@ Info box of level notice with a static title and a static text:
7781

7882
Warning box with disabled icon:
7983

80-
.. code-block:: html
84+
.. literalinclude:: _Infobox/_Warning.html
8185
:caption: EXT:my_extension/Resources/Private/Backend/Templates/MyModule.html
8286

83-
<f:be.infobox
84-
title="Message title"
85-
message="your box content"
86-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_WARNING')}"
87-
disableIcon="true"
88-
/>
89-
9087
Success box with custom icon:
9188

92-
.. code-block:: html
89+
.. literalinclude:: _Infobox/_CustomIcon.html
9390
:caption: EXT:my_extension/Resources/Private/Backend/Templates/MyModule.html
9491

95-
<f:be.infobox
96-
title="Message title"
97-
message="your box content"
98-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_OK')}"
99-
iconName="check"
100-
/>
101-
102-
10392
.. _typo3-fluid-be-infobox-example-html:
10493

10594
Infobox with HTML content, icon and links
@@ -112,6 +101,26 @@ You can find this example in the TYPO3 backend module
112101
.. literalinclude:: _Infobox/_ReferenceIndex.html
113102
:caption: EXT:lowlevel/Resources/Private/Templates/ReferenceIndex.html
114103

104+
.. _typo3-fluid-be-infobox-migration:
105+
106+
Migration from using InfoboxViewHelper state constants
107+
------------------------------------------------------
108+
109+
If you want to support both TYPO3 v13 and v14 you can keep using the constants
110+
until dropping TYPO3 13 support.
111+
112+
After dropping TYPO3 13 support migrate as follows:
113+
114+
.. literalinclude:: _Infobox/_Migration.diff
115+
:caption: EXT:my_extension/Resources/Private/Backend/Templates/MyModule.html
116+
117+
In PHP code replace the severity by using the enum or their value instead of the
118+
constants:
119+
120+
.. literalinclude:: _Infobox/_Migration.php
121+
:caption: EXT:my_extension/Classes/Controller/MyController.php
122+
123+
115124
.. _typo3-fluid-be-infobox-arguments:
116125

117126
Arguments
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<f:be.infobox
2+
title="Message title"
3+
message="your box content"
4+
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::OK')}"
5+
iconName="check"
6+
/>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<f:be.infobox title="Error!"
2+
- state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_ERROR')}">
3+
+ state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::ERROR')}">
4+
Error message
5+
</f:be.infobox>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
// Before
4+
use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper;
5+
6+
$state = InfoboxViewHelper::STATE_ERROR;
7+
8+
// After - Recommended: Use the enum directly
9+
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
10+
11+
$state = ContextualFeedbackSeverity::ERROR;
12+
13+
// Alternative: Use the integer value when explicitly needed
14+
$stateValue = ContextualFeedbackSeverity::ERROR->value;

Documentation/Global/Be/_Infobox/_ReferenceIndex.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<f:be.infobox
22
title="{f:translate(key:'LLL:EXT:lowlevel/Resources/Private/Language/locallang.xlf:checkScript_headline')}"
3-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_INFO')}"
3+
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO')}"
44
>
55
<p>{f:translate(key:'LLL:EXT:lowlevel/Resources/Private/Language/locallang.xlf:checkScript')}</p>
66
<p>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<f:be.infobox
22
title="Some Info"
33
message="The message"
4-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_NOTICE')}"
4+
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::NOTICE')}"
55
/>
66
<f:be.infobox
77
title="Some Notice"
88
message="The message"
9-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_INFO')}"
9+
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO')}"
1010
/>
1111
<f:be.infobox
1212
title="Some sucess message"
1313
message="The message"
14-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_OK')}"
14+
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::OK')}"
1515
/>
1616
<f:be.infobox
1717
title="Some Warning"
1818
message="The message"
19-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_WARNING')}"
19+
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::WARNING')}"
2020
/>
2121
<f:be.infobox
2222
title="Some Error"
2323
message="The message"
24-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_ERROR')}"
24+
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::ERROR')}"
2525
/>
Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
<f:be.infobox
2-
title="Some Info"
3-
message="The message"
4-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_NOTICE')}"
5-
/>
6-
<f:be.infobox
7-
title="Some Notice"
8-
message="The message"
9-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_INFO')}"
10-
/>
11-
<f:be.infobox
12-
title="Some sucess message"
13-
message="The message"
14-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_OK')}"
15-
/>
16-
<f:be.infobox
17-
title="Some Warning"
18-
message="The message"
19-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_WARNING')}"
20-
/>
21-
<f:be.infobox
22-
title="Some Error"
23-
message="The message"
24-
state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_ERROR')}"
2+
title="Message title"
3+
message="your box content"
4+
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::WARNING')}"
5+
disableIcon="true"
256
/>

0 commit comments

Comments
 (0)