‪TYPO3CMS  9.5
CacheModule.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
19 use Psr\Http\Message\ServerRequestInterface;
28 
30 {
34  public function ‪getIconIdentifier(): string
35  {
36  return 'apps-toolbar-menu-cache';
37  }
38 
42  public function ‪getPageSettings(): string
43  {
44  $view = GeneralUtility::makeInstance(StandaloneView::class);
45  $templateNameAndPath = 'EXT:adminpanel/Resources/Private/Templates/Modules/Settings/Cache.html';
46  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
47  $view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);
48 
49  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
50  $feCacheClear = $this->‪getBackendUser()->‪isAdmin() || $this->‪getBackendUser()->‪getTSConfig()['options.']['clearCache.']['pages'];
51 
52  $view->assignMultiple(
53  [
54  'isEnabled' => $this->‪getBackendUser()->uc['AdminPanel']['display_cache'],
55  'noCache' => $this->‪getBackendUser()->uc['AdminPanel']['cache_noCache'],
56  'currentId' => $this->‪getTypoScriptFrontendController()->id,
57  'clearPageCacheUrl' => $feCacheClear ? (string)$uriBuilder->buildUriFromRoute('tce_db', ['cacheCmd' => 'pages']) : '',
58  'clearCurrentPageCacheUrl' => (string)$uriBuilder->buildUriFromRoute(
59  'tce_db',
60  [
61  'cacheCmd' => $this->getTypoScriptFrontendController()->id,
62  ]
63  ),
64  ]
65  );
66 
67  return $view->render();
68  }
69 
73  public function ‪getIdentifier(): string
74  {
75  return 'cache';
76  }
77 
81  public function ‪getLabel(): string
82  {
83  $locallangFileAndPath = 'LLL:EXT:adminpanel/Resources/Private/Language/locallang_cache.xlf:module.label';
84  return $this->‪getLanguageService()->‪sL($locallangFileAndPath);
85  }
86 
90  public function ‪initializeModule(ServerRequestInterface $request): void
91  {
92  if ($this->configurationService->getConfigurationOption('cache', 'noCache')) {
93  $this->‪getTypoScriptFrontendController()->‪set_no_cache('Admin Panel: No Caching', true);
94  }
95  }
96 
101  {
102  return ‪$GLOBALS['TSFE'];
103  }
104 
108  public function ‪getJavaScriptFiles(): array
109  {
110  return ['EXT:adminpanel/Resources/Public/JavaScript/Modules/Cache.js'];
111  }
112 
120  public function ‪getCssFiles(): array
121  {
122  return [];
123  }
124 }
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule
Definition: AbstractModule.php:30
‪TYPO3\CMS\Adminpanel\Modules\CacheModule
Definition: CacheModule.php:30
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\initializeModule
‪initializeModule(ServerRequestInterface $request)
Definition: CacheModule.php:90
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\isAdmin
‪bool isAdmin()
Definition: BackendUserAuthentication.php:294
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController\set_no_cache
‪set_no_cache($reason='', $internal=false)
Definition: TypoScriptFrontendController.php:4399
‪TYPO3\CMS\Adminpanel\ModuleApi\InitializableInterface
Definition: InitializableInterface.php:34
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\getTSConfig
‪array getTSConfig($objectString=null, $config=null)
Definition: BackendUserAuthentication.php:1232
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getPageSettings
‪string getPageSettings()
Definition: CacheModule.php:42
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getLabel
‪getLabel()
Definition: CacheModule.php:81
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getIconIdentifier
‪string getIconIdentifier()
Definition: CacheModule.php:34
‪TYPO3\CMS\Core\Localization\LanguageService\sL
‪string sL($input)
Definition: LanguageService.php:158
‪TYPO3\CMS\Adminpanel\ModuleApi\ResourceProviderInterface
Definition: ResourceProviderInterface.php:26
‪TYPO3\CMS\Adminpanel\Modules
Definition: CacheModule.php:4
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:35
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getJavaScriptFiles
‪array getJavaScriptFiles()
Definition: CacheModule.php:108
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getLanguageService
‪LanguageService getLanguageService()
Definition: AbstractModule.php:120
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:32
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:97
‪TYPO3\CMS\Adminpanel\ModuleApi\PageSettingsProviderInterface
Definition: PageSettingsProviderInterface.php:31
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getTypoScriptFrontendController
‪TypoScriptFrontendController getTypoScriptFrontendController()
Definition: CacheModule.php:100
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getCssFiles
‪array getCssFiles()
Definition: CacheModule.php:120
‪TYPO3\CMS\Adminpanel\Modules\CacheModule\getIdentifier
‪getIdentifier()
Definition: CacheModule.php:73
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule\getBackendUser
‪BackendUserAuthentication FrontendBackendUserAuthentication getBackendUser()
Definition: AbstractModule.php:110