silverstripe-framework/tests/php/Control/HTTPCacheControlIntegrationTest/RuleController.php

46 lines
1.1 KiB
PHP
Raw Normal View History

2018-06-12 15:26:19 +02:00
<?php
namespace SilverStripe\Control\Tests\HTTPCacheControlIntegrationTest;
use SilverStripe\Control\Controller;
use SilverStripe\Control\Middleware\HTTPCacheControlMiddleware;
use SilverStripe\Dev\TestOnly;
class RuleController extends Controller implements TestOnly
{
private static $url_segment = 'HTTPCacheControlIntegrationTest_RuleController';
private static $allowed_actions = [
'privateaction',
'publicaction',
'disabledaction',
];
protected function init()
{
parent::init();
// Prefer public by default
HTTPCacheControlMiddleware::singleton()->publicCache();
}
public function privateaction()
{
HTTPCacheControlMiddleware::singleton()->privateCache();
return 'private content';
}
public function publicaction()
{
HTTPCacheControlMiddleware::singleton()
->publicCache()
->setMaxAge(9000);
return 'public content';
}
public function disabledaction()
{
HTTPCacheControlMiddleware::singleton()->disableCache();
return 'uncached content';
}
}