‪TYPO3CMS  10.4
ClearPageCacheController.php
Go to the documentation of this file.
1 <?php
2 
3 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 
20 use Psr\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
29 
36 {
40  protected ‪$dataHandler;
41 
45  public function ‪__construct()
46  {
47  $this->dataHandler = GeneralUtility::makeInstance(DataHandler::class);
48  }
49 
56  public function ‪mainAction(ServerRequestInterface $request): ResponseInterface
57  {
58  $parsedBody = $request->getParsedBody();
59  $queryParams = $request->getQueryParams();
60  $pageUid = (int)($parsedBody['id'] ?? $queryParams['id'] ?? 0);
61  $message = $this->‪getLanguageService()->‪sL('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:clearcache.message.error');
62  $success = false;
64  $pageRow = ‪BackendUtility::readPageAccess($pageUid, $permissionClause);
65  if ($pageUid !== 0 && $this->‪getBackendUserAuthentication()->doesUserHaveAccess($pageRow, ‪Permission::PAGE_SHOW)) {
66  $this->dataHandler->start([], []);
67  $this->dataHandler->clear_cacheCmd($pageUid);
68  $message = $this->‪getLanguageService()->‪sL('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:clearcache.message.success');
69  $success = true;
70  }
71  return new ‪JsonResponse([
72  'success' => $success,
73  'title' => $this->‪getLanguageService()->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:clearcache.title'),
74  'message' => $message
75  ]);
76  }
77 
82  {
83  return ‪$GLOBALS['BE_USER'];
84  }
85 
91  protected function ‪getLanguageService(): ‪LanguageService
92  {
93  return ‪$GLOBALS['LANG'];
94  }
95 }
‪TYPO3\CMS\Core\DataHandling\DataHandler
Definition: DataHandler.php:84
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\getPagePermsClause
‪string getPagePermsClause($perms)
Definition: BackendUserAuthentication.php:499
‪TYPO3\CMS\Core\Localization\LanguageService\sL
‪string sL($input)
Definition: LanguageService.php:194
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:24
‪TYPO3\CMS\Recordlist\Controller\ClearPageCacheController\mainAction
‪ResponseInterface mainAction(ServerRequestInterface $request)
Definition: ClearPageCacheController.php:55
‪TYPO3\CMS\Recordlist\Controller\ClearPageCacheController\__construct
‪__construct()
Definition: ClearPageCacheController.php:44
‪TYPO3\CMS\Recordlist\Controller
Definition: AbstractLinkBrowserController.php:16
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:33
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Recordlist\Controller\ClearPageCacheController\getBackendUserAuthentication
‪BackendUserAuthentication getBackendUserAuthentication()
Definition: ClearPageCacheController.php:80
‪TYPO3\CMS\Backend\Utility\BackendUtility\readPageAccess
‪static array false readPageAccess($id, $perms_clause)
Definition: BackendUtility.php:597
‪TYPO3\CMS\Core\Http\JsonResponse
Definition: JsonResponse.php:26
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Recordlist\Controller\ClearPageCacheController\getLanguageService
‪TYPO3 CMS Core Localization LanguageService getLanguageService()
Definition: ClearPageCacheController.php:90
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Recordlist\Controller\ClearPageCacheController
Definition: ClearPageCacheController.php:36
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Recordlist\Controller\ClearPageCacheController\$dataHandler
‪DataHandler $dataHandler
Definition: ClearPageCacheController.php:39