mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
b269badfbe
API CHANGE: Pass Object::create() calls to Injector::create(). API CHANGE: Add "RequestProcessor" injection point in Director, that Director will call preRequest() and postRequest() on.
41 lines
922 B
PHP
41 lines
922 B
PHP
<?php
|
|
|
|
/**
|
|
* A class that proxies another, allowing various functionality to be
|
|
* injected
|
|
*
|
|
* @author marcus@silverstripe.com.au
|
|
* @package sapphire
|
|
* @subpackage injector
|
|
*
|
|
* @license http://silverstripe.org/bsd-license/
|
|
*/
|
|
class AopProxyService {
|
|
public $beforeCall = array();
|
|
|
|
public $afterCall = array();
|
|
|
|
public $proxied;
|
|
|
|
public function __call($method, $args) {
|
|
if (method_exists($this->proxied, $method)) {
|
|
$continue = true;
|
|
if (isset($this->beforeCall[$method])) {
|
|
$result = $this->beforeCall[$method]->beforeCall($this->proxied, $method, $args);
|
|
if ($result === false) {
|
|
$continue = false;
|
|
}
|
|
}
|
|
|
|
if ($continue) {
|
|
$result = call_user_func_array(array($this->proxied, $method), $args);
|
|
|
|
if (isset($this->afterCall[$method])) {
|
|
$this->afterCall[$method]->afterCall($this->proxied, $method, $args, $result);
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|
|
}
|
|
} |