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