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