mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
2b316e79e5
Provides an interface for classes to implement their own flush() functionality. This function gets called early in a request on all implementations of Flushable when flush=1|all is requested in the URL. This fix came out of an issue where Requirements combined files were not being cleaned up after dev/build?flush=1, due to the fact that flush would only occur when you called it while on a page that used those combined files, but not in any other contexts. This will now call flush on any implementors of Flushable regardless of the context of where flush was called.
49 lines
1.0 KiB
PHP
49 lines
1.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Represents a request processer that delegates pre and post request handling to nested request filters
|
|
*
|
|
* @package framework
|
|
* @subpackage control
|
|
*/
|
|
class RequestProcessor implements RequestFilter {
|
|
|
|
/**
|
|
* List of currently assigned request filters
|
|
*
|
|
* @var array
|
|
*/
|
|
private $filters = array();
|
|
|
|
public function __construct($filters = array()) {
|
|
$this->filters = $filters;
|
|
}
|
|
|
|
/**
|
|
* Assign a list of request filters
|
|
*
|
|
* @param array $filters
|
|
*/
|
|
public function setFilters($filters) {
|
|
$this->filters = $filters;
|
|
}
|
|
|
|
public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model) {
|
|
foreach ($this->filters as $filter) {
|
|
$res = $filter->preRequest($request, $session, $model);
|
|
if ($res === false) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model) {
|
|
foreach ($this->filters as $filter) {
|
|
$res = $filter->postRequest($request, $response, $model);
|
|
if ($res === false) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|