‪TYPO3CMS  ‪main
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;
22 use TYPO3\CMS\Backend\Utility\BackendUtility;
29 
36 {
40  protected ‪$dataHandler;
41 
42  public function ‪__construct()
43  {
44  $this->dataHandler = GeneralUtility::makeInstance(DataHandler::class);
45  }
46 
50  public function ‪mainAction(ServerRequestInterface $request): ResponseInterface
51  {
52  $parsedBody = $request->getParsedBody();
53  $queryParams = $request->getQueryParams();
54  $pageUid = (int)($parsedBody['id'] ?? $queryParams['id'] ?? 0);
55  $message = $this->‪getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang.xlf:clearcache.message.error');
56  $success = false;
57  $permissionClause = $this->‪getBackendUserAuthentication()->getPagePermsClause(‪Permission::PAGE_SHOW);
58  $pageRow = BackendUtility::readPageAccess($pageUid, $permissionClause);
59  if ($pageUid !== 0 && $this->‪getBackendUserAuthentication()->doesUserHaveAccess($pageRow, ‪Permission::PAGE_SHOW)) {
60  $this->dataHandler->start([], []);
61  $this->dataHandler->clear_cacheCmd($pageUid);
62  $message = $this->‪getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang.xlf:clearcache.message.success');
63  $success = true;
64  }
65  return new JsonResponse([
66  'success' => $success,
67  'title' => $this->‪getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang.xlf:clearcache.title'),
68  'message' => $message,
69  ]);
70  }
71 
73  {
74  return ‪$GLOBALS['BE_USER'];
75  }
76 
77  protected function ‪getLanguageService(): ‪LanguageService
78  {
79  return ‪$GLOBALS['LANG'];
80  }
81 }
‪TYPO3\CMS\Core\DataHandling\DataHandler
Definition: DataHandler.php:94
‪TYPO3\CMS\Backend\Controller\ClearPageCacheController\$dataHandler
‪DataHandler $dataHandler
Definition: ClearPageCacheController.php:39
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:26
‪TYPO3\CMS\Backend\Controller\ClearPageCacheController\getLanguageService
‪getLanguageService()
Definition: ClearPageCacheController.php:76
‪TYPO3\CMS\Backend\Controller\ClearPageCacheController\mainAction
‪mainAction(ServerRequestInterface $request)
Definition: ClearPageCacheController.php:49
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:35
‪TYPO3\CMS\Backend\Controller\ClearPageCacheController
Definition: ClearPageCacheController.php:36
‪TYPO3\CMS\Backend\Controller\ClearPageCacheController\getBackendUserAuthentication
‪getBackendUserAuthentication()
Definition: ClearPageCacheController.php:71
‪TYPO3\CMS\Core\Http\JsonResponse
Definition: JsonResponse.php:28
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Controller\ClearPageCacheController\__construct
‪__construct()
Definition: ClearPageCacheController.php:41
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Backend\Controller
Definition: AboutController.php:18