From 4486d9d7a228f8b50d1613e6bd601c147b611668 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 1 Mar 2016 09:14:06 +0000 Subject: [PATCH] fix namespace usage in refactured code: namespace EGroupware\Api --> use eg. just Db, not Api\Db for EGroupware\Api\Db use EGroupware\Api --> use eg. Api\Db for EGroupware\Api\Db --- api/src/Cache.php | 18 +++++++++--------- api/src/Vfs.php | 38 +++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/api/src/Cache.php b/api/src/Cache.php index 2c0d0c5a03..33a0e8edbb 100644 --- a/api/src/Cache.php +++ b/api/src/Cache.php @@ -118,7 +118,7 @@ class Cache { case self::SESSION: case self::REQUEST: - throw new Api\Exception\WrongParameter(__METHOD__."('$level', ...) unsupported level parameter!"); + throw new Exception\WrongParameter(__METHOD__."('$level', ...) unsupported level parameter!"); case self::INSTANCE: case self::TREE: @@ -134,13 +134,13 @@ class Cache } return $provider->add(self::keys($level,$app,$location),$data,$expiration); } - throw new Api\Exception\WrongParameter(__METHOD__."() unknown level '$level'!"); + throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!"); } /** * Set some data in the cache * - * @param string $level use Api\Cache::(TREE|INSTANCE|SESSION|REQUEST) + * @param string $level use Cache::(TREE|INSTANCE|SESSION|REQUEST) * @param string $app application storing data * @param string $location location name for data * @param mixed $data @@ -170,7 +170,7 @@ class Cache } return $provider->set(self::keys($level,$app,$location),$data,$expiration); } - throw new Api\Exception\WrongParameter(__METHOD__."() unknown level '$level'!"); + throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!"); } /** @@ -209,7 +209,7 @@ class Cache { if (!is_null($callback)) { - throw new Api\Exception\WrongParameter(__METHOD__."() you can NOT use multiple locations (\$location parameter is an array) together with a callback!"); + throw new Exception\WrongParameter(__METHOD__."() you can NOT use multiple locations (\$location parameter is an array) together with a callback!"); } if (is_a($provider, 'EGroupware\Api\Cache\ProviderMultiple')) { @@ -246,7 +246,7 @@ class Cache } return $data; } - throw new Api\Exception\WrongParameter(__METHOD__."() unknown level '$level'!"); + throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!"); } /** @@ -274,7 +274,7 @@ class Cache } return $provider->delete(self::keys($level,$app,$location)); } - throw new Api\Exception\WrongParameter(__METHOD__."() unknown level '$level'!"); + throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!"); } /** @@ -590,7 +590,7 @@ class Cache error_log(__METHOD__."('$name', $throw) config value NOT found!");//.function_backtrace()); } } - catch(Api\Db\Exception $e) + catch(Db\Exception $e) { if ($throw) error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage());//.function_backtrace()); } @@ -729,7 +729,7 @@ class Cache */ function __construct() { - throw new Api\Exception\WrongParameter("All methods of class ".__CLASS__." should be called static!"); + throw new Exception\WrongParameter("All methods of class ".__CLASS__." should be called static!"); } } diff --git a/api/src/Vfs.php b/api/src/Vfs.php index 0ab5bc45b2..8a4b32f21a 100644 --- a/api/src/Vfs.php +++ b/api/src/Vfs.php @@ -119,7 +119,7 @@ class Vfs extends Vfs\StreamWrapper /** * Reference to the global db object * - * @var Api\Db + * @var Db */ static $db; @@ -134,7 +134,7 @@ class Vfs extends Vfs\StreamWrapper { if ($path[0] != '/') { - throw new Api\Exception\AssertionFailed("Filename '$path' is not an absolute path!"); + throw new Exception\AssertionFailed("Filename '$path' is not an absolute path!"); } return fopen(self::PREFIX.$path,$mode); } @@ -149,7 +149,7 @@ class Vfs extends Vfs\StreamWrapper { if ($path[0] != '/') { - throw new Api\Exception\AssertionFailed("Directory '$path' is not an absolute path!"); + throw new Exception\AssertionFailed("Directory '$path' is not an absolute path!"); } return opendir(self::PREFIX.$path); } @@ -164,7 +164,7 @@ class Vfs extends Vfs\StreamWrapper { if ($path[0] != '/') { - throw new Api\Exception\AssertionFailed("Directory '$path' is not an absolute path!"); + throw new Exception\AssertionFailed("Directory '$path' is not an absolute path!"); } return dir(self::PREFIX.$path); } @@ -180,7 +180,7 @@ class Vfs extends Vfs\StreamWrapper { if ($path[0] != '/') { - throw new Api\Exception\AssertionFailed("Directory '$path' is not an absolute path!"); + throw new Exception\AssertionFailed("Directory '$path' is not an absolute path!"); } return scandir(self::PREFIX.$path,$sorting_order); } @@ -243,7 +243,7 @@ class Vfs extends Vfs\StreamWrapper { if ($path[0] != '/') { - throw new Api\Exception\AssertionFailed("File '$path' is not an absolute path!"); + throw new Exception\AssertionFailed("File '$path' is not an absolute path!"); } if (($stat = self::url_stat($path,0,$try_create_home))) { @@ -263,7 +263,7 @@ class Vfs extends Vfs\StreamWrapper { if ($path[0] != '/') { - throw new Api\Exception\AssertionFailed("File '$path' is not an absolute path!"); + throw new Exception\AssertionFailed("File '$path' is not an absolute path!"); } if (($stat = self::url_stat($path,STREAM_URL_STAT_LINK,$try_create_home))) { @@ -758,7 +758,7 @@ class Vfs extends Vfs\StreamWrapper * * @param string|array $urls url or array of url's * @param boolean $allow_urls =false allow to use url's, default no only pathes (to stay within the vfs) - * @throws Api\Exception\AssertionFailed when trainig to remove /, /apps or /home + * @throws Exception\AssertionFailed when trainig to remove /, /apps or /home * @return array */ static function remove($urls,$allow_urls=false) @@ -769,7 +769,7 @@ class Vfs extends Vfs\StreamWrapper { if (preg_match('/^\/?(home|apps|)\/*$/',self::parse_url($url,PHP_URL_PATH))) { - throw new Api\Exception\AssertionFailed(__METHOD__.'('.array2string($urls).") Cautiously rejecting to remove folder '$url'!"); + throw new Exception\AssertionFailed(__METHOD__.'('.array2string($urls).") Cautiously rejecting to remove folder '$url'!"); } } return self::find($urls,array('depth'=>true,'url'=>$allow_urls,'hidden'=>true),array(__CLASS__,'_rm_rmdir')); @@ -869,7 +869,7 @@ class Vfs extends Vfs\StreamWrapper // throw exception if stat array is used insead of path, can be removed soon if (is_array($path)) { - throw new Api\Exception\WrongParameter('path has to be string, use check_access($path,$check,$stat=null)!'); + throw new Exception\WrongParameter('path has to be string, use check_access($path,$check,$stat=null)!'); } // query stat array, if not given if (is_null($stat)) @@ -1091,7 +1091,7 @@ class Vfs extends Vfs\StreamWrapper if (!preg_match($use='/^([ugoa]*)([+=-]+)([rwx]+)$/',$s,$matches)) { $use = str_replace(array('/','^','$','(',')'),'',$use); - throw new Api\Exception\WrongUserInput("$s is not an allowed mode, use $use !"); + throw new Exception\WrongUserInput("$s is not an allowed mode, use $use !"); } $base = (strpos($matches[3],'r') !== false ? self::READABLE : 0) | (strpos($matches[3],'w') !== false ? self::WRITABLE : 0) | @@ -1436,7 +1436,7 @@ class Vfs extends Vfs\StreamWrapper $zip = new \ZipArchive(); if (!$zip->open($zip_file, \ZipArchive::OVERWRITE)) { - throw new Api\Exception("Cannot open zip file for writing."); + throw new Exception("Cannot open zip file for writing."); } // Find lowest common directory, to use relative paths @@ -1648,8 +1648,8 @@ class Vfs extends Vfs\StreamWrapper ),__LINE__,__FILE__)->fetch()))) { $owner = $row['lock_owner']; - $scope = Api\Db::from_bool($row['lock_exclusive']) ? 'exclusive' : 'shared'; - $type = Api\Db::from_bool($row['lock_write']) ? 'write' : 'read'; + $scope = Db::from_bool($row['lock_exclusive']) ? 'exclusive' : 'shared'; + $type = Db::from_bool($row['lock_write']) ? 'write' : 'read'; self::$db->update(self::LOCK_TABLE,array( 'lock_expires' => $timeout, @@ -1694,7 +1694,7 @@ class Vfs extends Vfs\StreamWrapper ),false,__LINE__,__FILE__); $ret = true; } - catch(Api\Db\Exception $e) { + catch(Db\Exception $e) { unset($e); $ret = false; // there's already a lock } @@ -1749,10 +1749,10 @@ class Vfs extends Vfs\StreamWrapper // ToDo: shared locks can return multiple rows if (($result = self::$db->select(self::LOCK_TABLE,'*',$where,__LINE__,__FILE__)->fetch())) { - $result = Api\Db::strip_array_keys($result,'lock_'); - $result['type'] = Api\Db::from_bool($result['write']) ? 'write' : 'read'; - $result['scope'] = Api\Db::from_bool($result['exclusive']) ? 'exclusive' : 'shared'; - $result['depth'] = Api\Db::from_bool($result['recursive']) ? 'infinite' : 0; + $result = Db::strip_array_keys($result,'lock_'); + $result['type'] = Db::from_bool($result['write']) ? 'write' : 'read'; + $result['scope'] = Db::from_bool($result['exclusive']) ? 'exclusive' : 'shared'; + $result['depth'] = Db::from_bool($result['recursive']) ? 'infinite' : 0; } if ($result && $result['expires'] < time()) // lock is expired --> remove it {