‪TYPO3CMS  10.4
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() || $this->‪getBackendUser()->‪getTSConfig()['options.']['clearCache.']['pages'];
52 
53  $pageId = 0;
54  $pageArguments = ‪$GLOBALS['TYPO3_REQUEST']->getAttribute('routing');
55  if ($pageArguments instanceof ‪PageArguments) {
56  $pageId = $pageArguments->getPageId();
57  }
58 
59  $view->assignMultiple(
60  [
61  'isEnabled' => $this->‪getBackendUser()->uc['AdminPanel']['display_cache'],
62  'noCache' => $this->‪getBackendUser()->uc['AdminPanel']['cache_noCache'],
63  'currentId' => $pageId,
64  'clearPageCacheUrl' => $feCacheClear ? (string)$uriBuilder->buildUriFromRoute('tce_db', ['cacheCmd' => 'pages']) : '',
65  'clearCurrentPageCacheUrl' => (string)$uriBuilder->buildUriFromRoute(
66  'tce_db',
67  [
68  'cacheCmd' => $pageId,
69  ]
70  ),
71  'languageKey' => $this->getBackendUser()->user['lang'],
72  ]
73  );
74 
75  return $view->render();
76  }
77 
81  public function ‪getIdentifier(): string
82  {
83  return 'cache';
84  }
85 
89  public function ‪getLabel(): string
90  {
91  $locallangFileAndPath = 'LLL:EXT:adminpanel/Resources/Private/Language/locallang_cache.xlf:module.label';
92  return $this->‪getLanguageService()->‪sL($locallangFileAndPath);
93  }
94 
98  public function ‪enrich(ServerRequestInterface $request): ServerRequestInterface
99  {
100  if ($this->configurationService->getConfigurationOption('cache', 'noCache')) {
101  $request = $request->withAttribute('noCache', true);
102  }
103  return $request;
104  }
105 
109  public function ‪getJavaScriptFiles(): array
110  {
111  return ['EXT:adminpanel/Resources/Public/JavaScript/Modules/Cache.js'];
112  }
113 
121  public function ‪getCssFiles(): array
122  {
123  return [];
124  }
125 }
‪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\getTSConfig
‪array getTSConfig()
Definition: BackendUserAuthentication.php:1217
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\isAdmin
‪bool isAdmin()
Definition: BackendUserAuthentication.php:292
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getPageSettings
‪string getPageSettings()
Definition: CacheModule.php:43
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getLabel
‪getLabel()
Definition: CacheModule.php:89
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getIconIdentifier
‪string getIconIdentifier()
Definition: CacheModule.php:35
‪TYPO3\CMS\Core\Localization\LanguageService\sL
‪string sL($input)
Definition: LanguageService.php:194
‪TYPO3\CMS\Adminpanel\ModuleApi\ResourceProviderInterface
Definition: ResourceProviderInterface.php:27
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\enrich
‪enrich(ServerRequestInterface $request)
Definition: CacheModule.php:98
‪TYPO3\CMS\Adminpanel\Modules
Definition: CacheModule.php:18
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:38
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getJavaScriptFiles
‪array getJavaScriptFiles()
Definition: CacheModule.php:109
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getLanguageService
‪LanguageService getLanguageService()
Definition: AbstractModule.php:121
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:34
‪TYPO3\CMS\Adminpanel\ModuleApi\PageSettingsProviderInterface
Definition: PageSettingsProviderInterface.php:32
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getCssFiles
‪array getCssFiles()
Definition: CacheModule.php:121
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getIdentifier
‪getIdentifier()
Definition: CacheModule.php:81
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getBackendUser
‪BackendUserAuthentication FrontendBackendUserAuthentication getBackendUser()
Definition: AbstractModule.php:111
‪TYPO3\CMS\Adminpanel\ModuleApi\RequestEnricherInterface
Definition: RequestEnricherInterface.php:37