1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ApacheSolrForTypo3\Solr\System\Hooks\Backend\Toolbar; |
4
|
|
|
|
5
|
|
|
/*************************************************************** |
6
|
|
|
* Copyright notice |
7
|
|
|
* |
8
|
|
|
* (c) 2018 Timo Hund <[email protected]> |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
|
28
|
|
|
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; |
29
|
|
|
use TYPO3\CMS\Backend\Routing\UriBuilder; |
30
|
|
|
use TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface; |
31
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
32
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Class ClearCacheActionsHook |
36
|
|
|
* @package ApacheSolrForTypo3\Solr\System\Hooks\Backend\Toolbar |
37
|
|
|
*/ |
38
|
|
|
class ClearCacheActionsHook implements ClearCacheActionsHookInterface |
39
|
|
|
{ |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var UriBuilder |
43
|
|
|
*/ |
44
|
|
|
protected $uriBuilder; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var BackendUserAuthentication |
48
|
|
|
*/ |
49
|
|
|
protected $backendUser; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* ClearCacheActionsHook constructor. |
53
|
|
|
* @param UriBuilder|null $uriBuilder |
54
|
|
|
* @param BackendUserAuthentication|null $backendUser |
55
|
|
|
*/ |
56
|
2 |
|
public function __construct(UriBuilder $uriBuilder = null, BackendUserAuthentication $backendUser = null) |
57
|
|
|
{ |
58
|
2 |
|
$this->uriBuilder = $uriBuilder ?? GeneralUtility::makeInstance(UriBuilder::class); |
59
|
2 |
|
$this->backendUser = $backendUser ?? $GLOBALS['BE_USER']; |
60
|
2 |
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Adds a menu entry to the clear cache menu to detect Solr connections. |
64
|
|
|
* |
65
|
|
|
* @param array $cacheActions Array of CacheMenuItems |
66
|
|
|
* @param array $optionValues Array of AccessConfigurations-identifiers (typically used by userTS with options.clearCache.identifier) |
67
|
|
|
*/ |
68
|
2 |
|
public function manipulateCacheActions(&$cacheActions, &$optionValues) |
69
|
|
|
{ |
70
|
2 |
|
if (!$this->backendUser->isAdmin()) { |
71
|
1 |
|
return; |
72
|
|
|
} |
73
|
|
|
|
74
|
1 |
|
$href = $this->uriBuilder->buildUriFromRoute('ajax_solr_updateConnections'); |
75
|
1 |
|
$optionValues[] = 'clearSolrConnectionCache'; |
76
|
1 |
|
$cacheActions[] = [ |
77
|
1 |
|
'id' => 'clearSolrConnectionCache', |
78
|
1 |
|
'title' => 'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:cache_initialize_solr_connections', |
79
|
1 |
|
'href' => $href, |
80
|
1 |
|
'iconIdentifier' => 'extensions-solr-module-initsolrconnections' |
81
|
|
|
]; |
82
|
|
|
} |
83
|
|
|
} |