‪TYPO3CMS  9.5
UserElement.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
28 {
34  public function ‪render()
35  {
36  $parameterArray = $this->data['parameterArray'];
37  $resultArray = $this->‪initializeResultArray();
38 
39  if (empty($parameterArray['fieldConf']['config']['userFunc'])) {
40  // If there is no (deprecated) userFunc, render some dummy output to explain this element
41  // should usually not be called at all.
42  // @deprecated The if can be removed in TYPO3 v10.0, keeping the body only.
43  $resultArray['html'] = '<div class="alert alert-warning">';
44  $resultArray['html'] .= 'This is dummy output: Field <code>' . htmlspecialchars($this->data['fieldName']) . '</code>';
45  $resultArray['html'] .= 'of table <code>' . htmlspecialchars($this->data['tableName']) . '</code>';
46  $resultArray['html'] .= ' is registered as type="user" element without a specific renderType.';
47  $resultArray['html'] .= ' Please look up details in TCA reference documentation for type="user".';
48  $resultArray['html'] .= '</div>';
49  return $resultArray;
50  }
51 
52  // @deprecated since TYPO3 v9, everything below will be removed in TYPO3 v10.0.
53  trigger_error(
54  'Properties "userFunc", "noTableWrapping" and "parameters" will be removed in TYPO3 v10.0. Use a renderType instead.',
55  E_USER_DEPRECATED
56  );
57  $parameterArray['table'] = $this->data['tableName'];
58  $parameterArray['field'] = $this->data['fieldName'];
59  $parameterArray['row'] = $this->data['databaseRow'];
60  $parameterArray['parameters'] = $parameterArray['fieldConf']['config']['parameters'] ?? [];
61  $html = GeneralUtility::callUserFunction(
62  $parameterArray['fieldConf']['config']['userFunc'],
63  $parameterArray,
64  $this
65  );
66  if (!isset($parameterArray['fieldConf']['config']['noTableWrapping'])
67  || (bool)$parameterArray['fieldConf']['config']['noTableWrapping'] === false
68  ) {
69  $html = '<div class="formengine-field-item t3js-formengine-field-item">' . $html . '</div>';
70  }
71  $resultArray['html'] = $html;
72  return $resultArray;
73  }
74 }
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪array initializeResultArray()
Definition: AbstractNode.php:88
‪TYPO3\CMS\Backend\Form\Element\AbstractFormElement
Definition: AbstractFormElement.php:31
‪TYPO3\CMS\Backend\Form\Element
Definition: AbstractFormElement.php:2
‪TYPO3\CMS\Backend\Form\Element\UserElement\render
‪array render()
Definition: UserElement.php:34
‪TYPO3\CMS\Backend\Form\Element\UserElement
Definition: UserElement.php:28
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45