Skip to content

Commit 949e7f7

Browse files
authored
[TASK] Remove leftover reference to EMU::getFileFieldTCAConfig() (#5408)
* [TASK] Remove leftover reference to EMU::getFileFieldTCAConfig() Releases: main, 13.4, 12.4 * [TASK] Remove leftover reference to EMU::getFileFieldTCAConfig() Releases: main, 13.4, 12.4 * [TASK] Remove leftover reference to EMU::getFileFieldTCAConfig() Releases: main, 13.4, 12.4 * [TASK] Remove leftover reference to EMU::getFileFieldTCAConfig() Releases: main, 13.4, 12.4
1 parent bd3370b commit 949e7f7

File tree

4 files changed

+32
-106
lines changed

4 files changed

+32
-106
lines changed

Documentation/CodeSnippets/Config/Tutorials/Tea.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@
3838
'sourceFile' => 'EXT:tea/ext_emconf.php',
3939
'targetFileName' => 'CodeSnippets/Tutorials/Tea/ExtEmconf.rst.txt',
4040
],
41-
[
42-
'action' => 'createCodeSnippet',
43-
'caption' => 'EXT:tea/ext_tables.sql',
44-
'sourceFile' => 'EXT:tea/ext_tables.sql',
45-
'targetFileName' => 'CodeSnippets/Tutorials/Tea/ExtTablesSql.rst.txt',
46-
'language' => 'sql',
47-
],
4841
[
4942
'action' => 'createPhpArrayCodeSnippet',
5043
'caption' => 'EXT:tea/Configuration/TCA/tx_tea_domain_model_product_tea.php',
@@ -61,14 +54,6 @@
6154
'showLineNumbers' => true,
6255
'targetFileName' => 'CodeSnippets/Tutorials/Tea/Configuration/TCA/TeaColumnTitle.rst.txt',
6356
],
64-
[
65-
'action' => 'createPhpArrayCodeSnippet',
66-
'caption' => 'EXT:tea/Configuration/TCA/tx_tea_domain_model_product_tea.php',
67-
'sourceFile' => 'EXT:tea/Configuration/TCA/tx_tea_domain_model_product_tea.php',
68-
'fields' => ['columns/image'],
69-
'showLineNumbers' => true,
70-
'targetFileName' => 'CodeSnippets/Tutorials/Tea/Configuration/TCA/TeaColumnImage.rst.txt',
71-
],
7257
[
7358
'action' => 'createPhpArrayCodeSnippet',
7459
'caption' => 'EXT:tea/Configuration/TCA/tx_tea_domain_model_product_tea.php',

Documentation/CodeSnippets/Tutorials/Tea/Configuration/TCA/TeaColumnImage.rst.txt

Lines changed: 0 additions & 26 deletions
This file was deleted.

Documentation/ExtensionArchitecture/Tutorials/Tea/Model.rst

Lines changed: 12 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,10 @@ Model: a bag of tea
1010

1111
We keep the model basic: Each tea can have a title, a description, and an optional image.
1212

13-
.. uml::
14-
15-
class Tea {
16-
title
17-
==
18-
description
19-
==
20-
image
21-
}
22-
2313
The title and description are strings, the image is stored as a relation
2414
to the model class :php:`\TYPO3\CMS\Extbase\Domain\Model\FileReference`, provided
2515
by Extbase.
2616

27-
2817
.. _extbase_tutorial_tea_model_database:
2918

3019
The database model
@@ -76,8 +65,6 @@ keys on the first level:
7665
describe at least one type. Here we define the order in which
7766
the fields are displayed in the backend.
7867

79-
80-
8168
.. _extbase_tutorial_tea_model_ctrl:
8269

8370
TCA :php:`ctrl` - Settings for the complete table
@@ -156,53 +143,16 @@ The other text fields are defined in a similar manner.
156143

157144
.. _extbase_tutorial_tea_model_columns_image:
158145

159-
The :php:`image` field
160-
~~~~~~~~~~~~~~~~~~~~~~
161-
162-
As the tea extension always supports two major TYPO3 versions it still uses
163-
the deprecated way of creating an image field in TCA. If your extension only
164-
has to support TYPO3 v12, you should use the field type :ref:`t3tca:columns-file`.
146+
The `image` field
147+
~~~~~~~~~~~~~~~~~
165148

166-
The image field is a special case, as it is created by a call to the API function
167-
:php:`\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig()`.
168-
This method returns a preconfigured array, and saves you from writing a long and complicated configuration array.
149+
Field type :ref:`t3tca:columns-file` can be used to upload files. As the image
150+
should be an image, we limit the allowed file extensions to the `common-image-types`.
151+
See also :ref:`TCA type 'file', property 'allowed' <t3tca:confval-file-allowed>`.
169152

170-
.. code-block:: php
153+
.. literalinclude:: _Model/_image_tca.php
171154
:caption: EXT:tea/Configuration/TCA/tx_tea_domain_model_tea.php
172155

173-
[
174-
'columns' => [
175-
'image' => [
176-
'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_tea.image',
177-
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
178-
'image',
179-
[
180-
'maxitems' => 1,
181-
'appearance' => [
182-
'collapseAll' => true,
183-
'useSortable' => false,
184-
'enabledControls' => [
185-
'hide' => false,
186-
],
187-
],
188-
]
189-
),
190-
],
191-
],
192-
];
193-
194-
.. tip::
195-
Do not worry about performance caused by the API call, the TCA files are
196-
cached in compiled form.
197-
198-
The array generated by the method
199-
:php:`ExtensionManagementUtility::getFileFieldTCAConfig()` looks like this:
200-
201-
.. include:: /CodeSnippets/Tutorials/Tea/Configuration/TCA/TeaColumnImage.rst.txt
202-
203-
You are probably happy that this was generated for you and that you did not have to type it
204-
yourself.
205-
206156
.. _extbase_tutorial_tea_model_types:
207157

208158
TCA :php:`types` - Configure the input form
@@ -219,11 +169,13 @@ backend input form, in the order they should be displayed.
219169
:ref:`TCA reference, showitem <t3tca:types-properties-showitem>` for
220170
details.
221171

172+
.. _extbase_tutorial_tea_model-tca-result:
173+
222174
Result - the complete TCA
223175
--------------------------
224176

225177
Have a look at the complete file
226-
`EXT:tea/Configuration/TCA/tx_tea_domain_model_tea.php <https://github.com/TYPO3-Documentation/tea/blob/main/Configuration/TCA/tx_tea_domain_model_tea.php>`__.
178+
`EXT:tea/Configuration/TCA/tx_tea_domain_model_tea.php <https://github.com/TYPO3BestPractices/tea/blob/main/Configuration/TCA/tx_tea_domain_model_tea.php>`_.
227179

228180
Now the edit form for tea records will look like this:
229181

@@ -244,6 +196,8 @@ The list of teas in the module :guilabel:`Web -> List` looks like this:
244196
Up to this point we have only used TYPO3 Core features. You can create
245197
tables and backend forms exactly the same way without using Extbase.
246198

199+
.. _extbase_tutorial_tea_model-entity:
200+
247201
The Extbase model
248202
=================
249203

@@ -284,11 +238,4 @@ The getter for the image also has to resolve the :ref:`lazy loading <extbase-ann
284238
.. include:: /CodeSnippets/Tutorials/Tea/Classes/Domain/Model/TeaImage.rst.txt
285239

286240
See the complete
287-
`class on Github: Tea <https://github.com/TYPO3-Documentation/tea/blob/main/Classes/Domain/Model/Tea.php>`__.
288-
289-
Next steps
290-
==========
291-
292-
.. TODO: Link this as soon as written
293-
294-
* The repository - Query for tea
241+
`class on Github: Tea <https://github.com/TYPO3BestPractices/tea/blob/main/Classes/Domain/Model/Tea.php>`_.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
return [
4+
// ...
5+
'columns' => [
6+
'image' => [
7+
'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_tea.image',
8+
'type' => 'file',
9+
'maxitems' => 1,
10+
'appearance' => [
11+
'collapseAll' => true,
12+
'useSortable' => false,
13+
'enabledControls' => [
14+
'hide' => false,
15+
],
16+
],
17+
'allowed' => 'common-image-types',
18+
],
19+
],
20+
];

0 commit comments

Comments
 (0)