‪TYPO3CMS  10.4
ContextHelpAjaxController.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
25 
31 {
39  public function ‪getHelpAction(ServerRequestInterface $request): ResponseInterface
40  {
41  $params = $request->getParsedBody()['params'] ?? $request->getQueryParams()['params'];
42  if (($params['action'] ?? '') !== 'getContextHelp') {
43  throw new \RuntimeException('Action must be set to "getContextHelp"', 1518787887);
44  }
45  $result = $this->‪getContextHelp($params['table'], $params['field']);
46  return new ‪JsonResponse([
47  'title' => $result['title'],
48  'content' => $result['description'],
49  'link' => $result['moreInfo']
50  ]);
51  }
52 
60  protected function ‪getContextHelp($table, $field)
61  {
62  $helpTextArray = ‪BackendUtility::helpTextArray($table, $field);
63  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
64  $moreIcon = $helpTextArray['moreInfo'] ? $iconFactory->getIcon('actions-view-go-forward', ‪Icon::SIZE_SMALL)->render() : '';
65  return [
66  'title' => $helpTextArray['title'],
67  'description' => '<p class="help-short' . ($moreIcon ? ' help-has-link' : '') . '">' . $helpTextArray['description'] . $moreIcon . '</p>',
68  'id' => $table . '.' . $field,
69  'moreInfo' => $helpTextArray['moreInfo']
70  ];
71  }
72 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Backend\Controller\ContextHelpAjaxController\getContextHelp
‪array getContextHelp($table, $field)
Definition: ContextHelpAjaxController.php:60
‪TYPO3\CMS\Backend\Controller\ContextHelpAjaxController
Definition: ContextHelpAjaxController.php:31
‪TYPO3\CMS\Backend\Controller\ContextHelpAjaxController\getHelpAction
‪ResponseInterface getHelpAction(ServerRequestInterface $request)
Definition: ContextHelpAjaxController.php:39
‪TYPO3\CMS\Core\Http\JsonResponse
Definition: JsonResponse.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\Utility\BackendUtility\helpTextArray
‪static array helpTextArray($table, $field)
Definition: BackendUtility.php:2188
‪TYPO3\CMS\Backend\Controller
Definition: AbstractFormEngineAjaxController.php:18