Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Classes/Controller/VarnishController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public static function ban($cacheObject) {
'Varnish-Ban-TYPO3-Pid: ' . (integer) $cacheObject,
$siteName
));
} elseif ($cacheObject === 'pages' || $cacheObject === 'all' || $cacheObject === 'system') {
} elseif ($cacheObject === 'pages' || $cacheObject === 'all') {
// do nothing
} elseif ($cacheObject === 'banAll') {
return HttpUtility::ban($url, array(
'Varnish-Ban-All: 1',
$siteName
Expand Down
3 changes: 1 addition & 2 deletions Classes/Hooks/Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
use Z7\Varnish\Controller\VarnishController;

class Ajax {

public function banAll() {
$logger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__);
$logger->info('User ' . $GLOBALS['BE_USER']->user['username'] . ' has cleared the varnish cache');
VarnishController::ban('all');
VarnishController::ban('banAll');
}
}
16 changes: 10 additions & 6 deletions Classes/Hooks/ClearCacheMenu.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Z7\Varnish\Hooks;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;

class ClearCacheMenu implements \TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface {

Expand All @@ -12,11 +13,14 @@ class ClearCacheMenu implements \TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHook
* @return void
*/
public function manipulateCacheActions(&$cacheActions, &$optionValues) {
$cacheActions[] = array(
'id' => 'varnish',
'title' => LocalizationUtility::translate('LLL:EXT:varnish/Resources/Private/Language/locallang.xlf:hooks.cache.title', $_EXTKEY),
'href' => 'ajax.php?ajaxID=varnish::banAll',
'icon' => '<img src="/' . $GLOBALS['TYPO3_LOADED_EXT']['varnish']['siteRelPath'] . 'Resources/Public/Icons/ClearVarnish.svg" width="16" height="16" />'
);
if ($GLOBALS['BE_USER']->isAdmin()) {
$cacheActions[] = array(
'id' => 'varnish',
'title' => LocalizationUtility::translate('LLL:EXT:varnish/Resources/Private/Language/locallang.xlf:hooks.cache.title', $_EXTKEY),
'href' => BackendUtility::getAjaxUrl('varnish::banAll'),
'icon' => '<img src="/' . $GLOBALS['TYPO3_LOADED_EXT']['varnish']['siteRelPath'] . 'Resources/Public/Icons/ClearVarnish.svg" width="16" height="16" />'
);
$optionValues[] = 'banAll';
}
}
}
2 changes: 1 addition & 1 deletion Classes/Utility/HttpUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function ban($url, $headers = array()) {
* @param array $headers
* @return array
*/
private function sendRequest($url, $verb, $headers) {
private static function sendRequest($url, $verb, $headers) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $verb);
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Install the extension.
## Thanks…

* …to snowflake for their [varnish-typo3](https://github.com/snowflakech/typo3-varnish) extension.
Most of this extension is modeled after theirs, but simplified a bit and it also works on 7.2.
Most of this extension is modeled after theirs, but simplified a bit and it also works on 7 LTS.

* …to varnish-software for openly sharing the superbunny graphics.

Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'constraints' => array(
'depends' => array(
'php' => '5.3.0-0.0.0',
'typo3' => '7.2.0-7.2.99',
'typo3' => '7.2.0-7.6.99',
),
'conflicts' => array(
),
Expand Down
16 changes: 8 additions & 8 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
}

if (TYPO3_MODE === 'BE') {
$TYPO3_CONF_VARS['SC_OPTIONS']['additionalBackendItems']['cacheActions'][] =
'EXT:' . $_EXTKEY . '/Classes/Hooks/ClearCacheMenu.php:Z7\\Varnish\\Hooks\\ClearCacheMenu';
$TYPO3_CONF_VARS['SC_OPTIONS']['additionalBackendItems']['cacheActions']['banAll'] =
'Z7\\Varnish\\Hooks\\ClearCacheMenu';
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'][] =
'EXT:' . $_EXTKEY . '/Classes/Hooks/ClearCache.php:Z7\\Varnish\\Hooks\\ClearCache->clearCache';
$TYPO3_CONF_VARS['BE']['AJAX']['varnish::banAll'] = array(
'callbackMethod' => 'EXT:' . $_EXTKEY . '/Classes/Hooks/Ajax.php:Z7\\Varnish\\Hooks\Ajax->banAll',
'csrfTokenCheck' => FALSE
);
'Z7\\Varnish\\Hooks\\ClearCache->clearCache';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerAjaxHandler(
'varnish::banAll',
'Z7\\Varnish\\Hooks\\Ajax->banAll'
);
}

if (TYPO3_MODE === 'FE') {
$TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'][] =
'EXT:' . $_EXTKEY . '/Classes/Hooks/Frontend.php:Z7\\Varnish\\Hooks\\Frontend->sendHeader';
'Z7\\Varnish\\Hooks\\Frontend->sendHeader';
}