mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
8dd644d25d
Namespace all templates Move difflib and BBCodeParser2 to thirdparty Remove deprecated API marked for removal in 4.0
54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\Control;
|
|
|
|
use SilverStripe\Core\Injector\Injectable;
|
|
use SilverStripe\ORM\DataModel;
|
|
|
|
/**
|
|
* Represents a request processer that delegates pre and post request handling to nested request filters
|
|
*/
|
|
class RequestProcessor implements RequestFilter {
|
|
use Injectable;
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|