WP_CLI
Autoloader::autoload()
The autoload function that gets registered with the SPL Autoloader system.
Метод класса: Autoloader{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$Autoloader = new Autoloader(); $Autoloader->autoload( $class );
- $class(строка) (обязательный)
- The class that got requested by the spl_autoloader.
Код Autoloader::autoload() Autoloader::autoload WP-CLI 2.8.0-alpha
public function autoload( $class ) { // Iterate over namespaces to find a match. foreach ( $this->namespaces as $namespace ) { // Move on if the object does not belong to the current namespace. if ( 0 !== strpos( $class, $namespace['root'] ) ) { continue; } // Remove namespace root level to correspond with root filesystem, and // replace the namespace separator "\" by the system-dependent directory separator. $filename = str_replace( [ $namespace['root'], '\\' ], [ '', DIRECTORY_SEPARATOR ], $class ); // Remove a leading backslash from the class name. $filename = $this->remove_leading_backslash( $filename ); // Change to lower case if requested. if ( $namespace['lowercase'] ) { $filename = strtolower( $filename ); } // Change underscores into hyphens if requested. if ( $namespace['underscores'] ) { $filename = str_replace( '_', '-', $filename ); } // Add base_dir, prefix and suffix. $filepath = $namespace['base_dir'] . $namespace['prefix'] . $filename . $namespace['suffix']; // Throw an exception if the file does not exist or is not readable. if ( is_readable( $filepath ) ) { require_once $filepath; } } }