You are here

static function Util::prefixLogicalPath in X Autoload 7.4

Same name and namespace in other branches
  1. 7.5 src/Util.php \Drupal\xautoload\Util::prefixLogicalPath()

Convert the underscores of a prefix into directory separators.

Parameters

string $prefix: Prefix, without trailing underscore.

Return value

string Path fragment representing the prefix, with trailing '/'.

10 calls to Util::prefixLogicalPath()
ClassFinder::add in lib/ClassFinder/ClassFinder.php
Add PSR-0 style prefixes. Alias for ->addPsr0().
ClassFinder::addPear in lib/ClassFinder/ClassFinder.php
Add PEAR-like prefix. This will assume with no further checks that $prefix contains no namespace separator.
ClassFinder::registerPrefixDeepLocation in lib/ClassFinder/ClassFinder.php
Register a filesystem location for a given class prefix.
ClassFinder::registerPrefixesDeep in lib/ClassFinder/ClassFinder.php
Register an array of PEAR-style deep paths for given class prefixes.
ClassFinder::registerPrefixesRoot in lib/ClassFinder/ClassFinder.php
Register an array of PEAR-style deep paths for given class prefixes.

... See full list

File

lib/Util.php, line 123

Class

Util
A number of static methods that don't interact with any global state.

Namespace

Drupal\xautoload

Code

static function prefixLogicalPath($prefix) {
  if (!strlen($prefix)) {
    return '';
  }
  $pear_logical_path = str_replace('_', '/', rtrim($prefix, '_') . '_');

  // Clean up surplus '/' resulting from duplicate underscores, or an
  // underscore at the beginning of the class.
  while (FALSE !== ($pos = strrpos('/' . $pear_logical_path, '//'))) {
    $pear_logical_path[$pos] = '_';
  }
  return $pear_logical_path;
}