Changeset 2762
- Timestamp:
- 03/17/2016 06:42:01 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-autoloader.php
r2621 r2762 8 8 */ 9 9 class Autoloader { 10 11 /** 12 * Namespace separator. 13 */ 10 14 const NS_SEPARATOR = '\\'; 15 16 /** 17 * The prefix to compare classes against. 18 * 19 * @var string 20 * @access protected 21 */ 11 22 protected $prefix; 23 24 /** 25 * Length of the prefix string. 26 * 27 * @var int 28 * @access protected 29 */ 12 30 protected $prefix_length; 31 32 /** 33 * Path to the file to be loaded. 34 * 35 * @var string 36 * @access protected 37 */ 13 38 protected $path; 14 39 40 /** 41 * Constructor. 42 * 43 * @param string $prefix Prefix all classes have in common. 44 * @param string $path Path to the files to be loaded. 45 */ 15 46 public function __construct( $prefix, $path ) { 16 47 $this->prefix = $prefix; … … 19 50 } 20 51 52 /** 53 * Loads a class if it starts with `$this->prefix`. 54 * 55 * @param string $class The class to be loaded. 56 */ 21 57 public function load( $class ) { 22 58 if ( strpos( $class, $this->prefix . self::NS_SEPARATOR ) !== 0 ) { … … 31 67 if ( false !== ( $last_ns_pos = strripos( $class, self::NS_SEPARATOR ) ) ) { 32 68 $namespace = substr( $class, 0, $last_ns_pos ); 69 $namespace = str_replace( '_', '-', $namespace ); 33 70 $class = substr( $class, $last_ns_pos + 1 ); 34 71 $file = str_replace( self::NS_SEPARATOR, DIRECTORY_SEPARATOR, $namespace ) . DIRECTORY_SEPARATOR; … … 45 82 } 46 83 84 /** 85 * Registers Autoloader's autoload function. 86 * 87 * @param string $prefix 88 * @param string $path 89 */ 47 90 function register_class_path( $prefix, $path ) { 48 91 $loader = new Autoloader( $prefix, $path );
Note: See TracChangeset
for help on using the changeset viewer.