Smarter code for OC_FileProxy
This commit is contained in:
parent
6af980c20c
commit
b9a1524508
|
@ -44,15 +44,6 @@ class OC_FileProxy{
|
||||||
private static $proxies=array();
|
private static $proxies=array();
|
||||||
public static $enabled=true;
|
public static $enabled=true;
|
||||||
|
|
||||||
/**
|
|
||||||
* check if this proxy implments a specific proxy operation
|
|
||||||
* @param string #proxy name of the proxy operation
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function provides($operation){
|
|
||||||
return method_exists($this,$operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fallback function when a proxy operation is not implemented
|
* fallback function when a proxy operation is not implemented
|
||||||
* @param string $function the name of the proxy operation
|
* @param string $function the name of the proxy operation
|
||||||
|
@ -76,11 +67,10 @@ class OC_FileProxy{
|
||||||
self::$proxies[]=$proxy;
|
self::$proxies[]=$proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getProxies($operation,$post){
|
public static function getProxies($operation){
|
||||||
$operation=(($post)?'post':'pre').$operation;
|
|
||||||
$proxies=array();
|
$proxies=array();
|
||||||
foreach(self::$proxies as $proxy){
|
foreach(self::$proxies as $proxy){
|
||||||
if($proxy->provides($operation)){
|
if(method_exists($proxy,$operation)){
|
||||||
$proxies[]=$proxy;
|
$proxies[]=$proxy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,8 +81,8 @@ class OC_FileProxy{
|
||||||
if(!self::$enabled){
|
if(!self::$enabled){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$proxies=self::getProxies($operation,false);
|
|
||||||
$operation='pre'.$operation;
|
$operation='pre'.$operation;
|
||||||
|
$proxies=self::getProxies($operation);
|
||||||
foreach($proxies as $proxy){
|
foreach($proxies as $proxy){
|
||||||
if(!is_null($filepath2)){
|
if(!is_null($filepath2)){
|
||||||
if($proxy->$operation($filepath,$filepath2)===false){
|
if($proxy->$operation($filepath,$filepath2)===false){
|
||||||
|
@ -111,8 +101,8 @@ class OC_FileProxy{
|
||||||
if(!self::$enabled){
|
if(!self::$enabled){
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
$proxies=self::getProxies($operation,true);
|
|
||||||
$operation='post'.$operation;
|
$operation='post'.$operation;
|
||||||
|
$proxies=self::getProxies($operation);
|
||||||
foreach($proxies as $proxy){
|
foreach($proxies as $proxy){
|
||||||
$result=$proxy->$operation($path,$result);
|
$result=$proxy->$operation($path,$result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue