summaryrefslogtreecommitdiffstats
path: root/lib/SimpleSAML
diff options
context:
space:
mode:
authorJaime Perez Crespo <jaime.perez@uninett.no>2015-04-21 11:56:47 +0200
committerJaime Perez Crespo <jaime.perez@uninett.no>2015-04-21 11:56:47 +0200
commitd73a986c1579cec32ff839cdcca0a209d9c4def7 (patch)
tree6429cc876fbcd4562f4c307ca5b8b2c56240d0b0 /lib/SimpleSAML
parent76f7f7a7cc886df8f7c8f7af4b447ca7c0a12aa6 (diff)
downloadsimplesamlphp-d73a986c1579cec32ff839cdcca0a209d9c4def7.zip
simplesamlphp-d73a986c1579cec32ff839cdcca0a209d9c4def7.tar.gz
simplesamlphp-d73a986c1579cec32ff839cdcca0a209d9c4def7.tar.bz2
Move SimpleSAML_Utilities:::resolvePath() to SimpleSAML\Utils\HTTP::resolvePath() and deprecate the former.
Diffstat (limited to 'lib/SimpleSAML')
-rw-r--r--lib/SimpleSAML/Utilities.php45
-rw-r--r--lib/SimpleSAML/Utils/HTTP.php53
2 files changed, 55 insertions, 43 deletions
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index 334f584..81d8a28 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -749,51 +749,10 @@ class SimpleSAML_Utilities {
/**
- * Resolve a (possibly) relative path from the given base path.
- *
- * A path which starts with a '/' is assumed to be absolute, all others are assumed to be
- * relative. The default base path is the root of the simpleSAMPphp installation.
- *
- * @param $path The path we should resolve.
- * @param $base The base path, where we should search for $path from. Default value is the root
- * of the simpleSAMLphp installation.
- * @return An absolute path referring to $path.
+ * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::resolvePath() instead.
*/
public static function resolvePath($path, $base = NULL) {
- if($base === NULL) {
- $config = SimpleSAML_Configuration::getInstance();
- $base = $config->getBaseDir();
- }
-
- /* Remove trailing slashes from $base. */
- while(substr($base, -1) === '/') {
- $base = substr($base, 0, -1);
- }
-
- /* Check for absolute path. */
- if(substr($path, 0, 1) === '/') {
- /* Absolute path. */
- $ret = '/';
- } else {
- /* Path relative to base. */
- $ret = $base;
- }
-
- $path = explode('/', $path);
- foreach($path as $d) {
- if($d === '.') {
- continue;
- } elseif($d === '..') {
- $ret = dirname($ret);
- } else {
- if(substr($ret, -1) !== '/') {
- $ret .= '/';
- }
- $ret .= $d;
- }
- }
-
- return $ret;
+ return \SimpleSAML\Utils\HTTP::resolvePath($path, $base);
}
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index 74f3421..5c50427 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -241,4 +241,57 @@ class HTTP
}
return $res;
}
+
+
+ /**
+ * Resolve a (possibly) relative path from the given base path.
+ *
+ * A path which starts with a '/' is assumed to be absolute, all others are assumed to be
+ * relative. The default base path is the root of the SimpleSAMPphp installation.
+ *
+ * @param string $path The path we should resolve.
+ * @param string|null $base The base path, where we should search for $path from. Default value is the root of the
+ * SimpleSAMLphp installation.
+ *
+ * @return string An absolute path referring to $path.
+ *
+ * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
+ */
+ public static function resolvePath($path, $base = null)
+ {
+ if ($base === null) {
+ $config = \SimpleSAML_Configuration::getInstance();
+ $base = $config->getBaseDir();
+ }
+
+ // remove trailing slashes from $base
+ while (substr($base, -1) === '/') {
+ $base = substr($base, 0, -1);
+ }
+
+ // check for absolute path
+ if (substr($path, 0, 1) === '/') {
+ // absolute path. */
+ $ret = '/';
+ } else {
+ // path relative to base
+ $ret = $base;
+ }
+
+ $path = explode('/', $path);
+ foreach ($path as $d) {
+ if ($d === '.') {
+ continue;
+ } elseif ($d === '..') {
+ $ret = dirname($ret);
+ } else {
+ if (substr($ret, -1) !== '/') {
+ $ret .= '/';
+ }
+ $ret .= $d;
+ }
+ }
+
+ return $ret;
+ }
} \ No newline at end of file