silverstripe-framework/Control/FlushRequestFilter.php

46 lines
907 B
PHP
Raw Normal View History

<?php
namespace SilverStripe\Control;
use SilverStripe\ORM\DataModel;
use SilverStripe\Core\ClassInfo;
/**
* Triggers a call to flush() on all implementors of Flushable.
*/
class FlushRequestFilter implements RequestFilter {
2015-11-13 23:44:49 +01:00
/**
* @inheritdoc
*
2016-09-09 08:43:05 +02:00
* @param HTTPRequest $request
2015-11-13 23:44:49 +01:00
* @param Session $session
* @param DataModel $model
*
* @return bool
*/
2016-09-09 08:43:05 +02:00
public function preRequest(HTTPRequest $request, Session $session, DataModel $model) {
if(array_key_exists('flush', $request->getVars())) {
foreach(ClassInfo::implementorsOf('SilverStripe\\Core\\Flushable') as $class) {
$class::flush();
}
}
return true;
2015-08-06 01:47:17 +02:00
}
2015-11-13 23:44:49 +01:00
/**
* @inheritdoc
*
2016-09-09 08:43:05 +02:00
* @param HTTPRequest $request
* @param HTTPResponse $response
2015-11-13 23:44:49 +01:00
* @param DataModel $model
*
* @return bool
*/
2016-09-09 08:43:05 +02:00
public function postRequest(HTTPRequest $request, HTTPResponse $response, DataModel $model) {
return true;
}
}