@@ -10,21 +10,10 @@ Model: a bag of tea
1010
1111We 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-
2313The title and description are strings, the image is stored as a relation
2414to the model class :php: `\T YPO3\C MS\E xtbase\D omain\M odel\F ileReference `, provided
2515by Extbase.
2616
27-
2817.. _extbase_tutorial_tea_model_database :
2918
3019The 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
8370TCA :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: ` \T YPO3 \C MS \C ore \U tility \E xtensionManagementUtility::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
208158TCA :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+
222174Result - the complete TCA
223175--------------------------
224176
225177Have 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
228180Now 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+
247201The 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
286240See 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 >`_.
0 commit comments