‪TYPO3CMS  11.5
CacheModule.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\ServerRequestInterface;
29 
31 {
35  public function ‪getIconIdentifier(): string
36  {
37  return 'apps-toolbar-menu-cache';
38  }
39 
43  public function ‪getPageSettings(): string
44  {
45  $view = GeneralUtility::makeInstance(StandaloneView::class);
46  $templateNameAndPath = 'EXT:adminpanel/Resources/Private/Templates/Modules/Settings/Cache.html';
47  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
48  $view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);
49 
50  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
51  $feCacheClear = $this->‪getBackendUser()->‪isAdmin()
52  || !empty($this->‪getBackendUser()->getTSConfig()['options.']['clearCache.']['pages']);
53 
54  $pageId = 0;
55  $pageArguments = ‪$GLOBALS['TYPO3_REQUEST']->getAttribute('routing');
56  if ($pageArguments instanceof ‪PageArguments) {
57  $pageId = $pageArguments->getPageId();
58  }
59 
60  $view->assignMultiple(
61  [
62  'isEnabled' => $this->‪getBackendUser()->uc['AdminPanel']['display_cache'] ?? false,
63  'noCache' => $this->‪getBackendUser()->uc['AdminPanel']['cache_noCache'] ?? false,
64  'currentId' => $pageId,
65  'clearPageCacheUrl' => $feCacheClear ? (string)$uriBuilder->buildUriFromRoute('tce_db', ['cacheCmd' => 'pages']) : '',
66  'clearCurrentPageCacheUrl' => (string)$uriBuilder->buildUriFromRoute(
67  'tce_db',
68  [
69  'cacheCmd' => $pageId,
70  ]
71  ),
72  'languageKey' => $this->getBackendUser()->user['lang'] ?? null,
73  ]
74  );
75 
76  return $view->render();
77  }
78 
82  public function ‪getIdentifier(): string
83  {
84  return 'cache';
85  }
86 
90  public function ‪getLabel(): string
91  {
92  $locallangFileAndPath = 'LLL:EXT:adminpanel/Resources/Private/Language/locallang_cache.xlf:module.label';
93  return $this->‪getLanguageService()->‪sL($locallangFileAndPath);
94  }
95 
99  public function ‪enrich(ServerRequestInterface $request): ServerRequestInterface
100  {
101  if ($this->configurationService->getConfigurationOption('cache', 'noCache')) {
102  $request = $request->withAttribute('noCache', true);
103  }
104  return $request;
105  }
106 
110  public function ‪getJavaScriptFiles(): array
111  {
112  return ['EXT:adminpanel/Resources/Public/JavaScript/Modules/Cache.js'];
113  }
114 
122  public function ‪getCssFiles(): array
123  {
124  return [];
125  }
126 }
‪TYPO3\CMS\Core\Routing\PageArguments
Definition: PageArguments.php:26
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule
Definition: AbstractModule.php:31
‪TYPO3\CMS\Adminpanel\Modules\CacheModule
Definition: CacheModule.php:31
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\isAdmin
‪bool isAdmin()
Definition: BackendUserAuthentication.php:245
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getPageSettings
‪string getPageSettings()
Definition: CacheModule.php:43
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getLabel
‪getLabel()
Definition: CacheModule.php:90
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getIconIdentifier
‪string getIconIdentifier()
Definition: CacheModule.php:35
‪TYPO3\CMS\Core\Localization\LanguageService\sL
‪string sL($input)
Definition: LanguageService.php:161
‪TYPO3\CMS\Adminpanel\ModuleApi\ResourceProviderInterface
Definition: ResourceProviderInterface.php:27
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\enrich
‪enrich(ServerRequestInterface $request)
Definition: CacheModule.php:99
‪TYPO3\CMS\Adminpanel\Modules
Definition: CacheModule.php:18
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:40
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getJavaScriptFiles
‪array getJavaScriptFiles()
Definition: CacheModule.php:110
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getLanguageService
‪LanguageService getLanguageService()
Definition: AbstractModule.php:120
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:31
‪TYPO3\CMS\Adminpanel\ModuleApi\PageSettingsProviderInterface
Definition: PageSettingsProviderInterface.php:32
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getCssFiles
‪array getCssFiles()
Definition: CacheModule.php:122
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getIdentifier
‪getIdentifier()
Definition: CacheModule.php:82
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getBackendUser
‪BackendUserAuthentication FrontendBackendUserAuthentication getBackendUser()
Definition: AbstractModule.php:110
‪TYPO3\CMS\Adminpanel\ModuleApi\RequestEnricherInterface
Definition: RequestEnricherInterface.php:37