]> source.dussan.org Git - nextcloud-server.git/commitdiff
Smarter code for OC_FileProxy
authorBart Visscher <bartv@thisnet.nl>
Fri, 8 Jun 2012 19:08:38 +0000 (21:08 +0200)
committerBart Visscher <bartv@thisnet.nl>
Fri, 8 Jun 2012 19:38:10 +0000 (21:38 +0200)
lib/fileproxy.php

index 180284f73dee84f15cac5005d3d2165c619d63c9..82c9298788cb9438b42e17c50870a72f402fb4d1 100644 (file)
@@ -44,15 +44,6 @@ class OC_FileProxy{
        private static $proxies=array();
        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
         * @param string $function the name of the proxy operation
@@ -76,11 +67,10 @@ class OC_FileProxy{
                self::$proxies[]=$proxy;
        }
        
-       public static function getProxies($operation,$post){
-               $operation=(($post)?'post':'pre').$operation;
+       public static function getProxies($operation){
                $proxies=array();
                foreach(self::$proxies as $proxy){
-                       if($proxy->provides($operation)){
+                       if(method_exists($proxy,$operation)){
                                $proxies[]=$proxy;
                        }
                }
@@ -91,8 +81,8 @@ class OC_FileProxy{
                if(!self::$enabled){
                        return true;
                }
-               $proxies=self::getProxies($operation,false);
                $operation='pre'.$operation;
+               $proxies=self::getProxies($operation);
                foreach($proxies as $proxy){
                        if(!is_null($filepath2)){
                                if($proxy->$operation($filepath,$filepath2)===false){
@@ -111,8 +101,8 @@ class OC_FileProxy{
                if(!self::$enabled){
                        return $result;
                }
-               $proxies=self::getProxies($operation,true);
                $operation='post'.$operation;
+               $proxies=self::getProxies($operation);
                foreach($proxies as $proxy){
                        $result=$proxy->$operation($path,$result);
                }