HumHub Documentation (unofficial)

ModuleAutoloader
in package
implements SplAutoloader

Table of Contents

Interfaces

SplAutoloader
Defines an interface for classes that may register with the spl_autoload registry

Properties

$explicitPaths  : array<string|int, mixed>
$moduleClassMap  : array<string|int, mixed>
$namespacedPaths  : array<string|int, mixed>
$paths  : array<string|int, mixed>
$pharBasePath  : string
$pharExtensions  : array<string|int, mixed>

Methods

__construct()  : mixed
Constructor
autoload()  : mixed
Autoload a class
getModuleClassMap()  : array<string|int, mixed>
Retrieves the class map for all loaded modules.
getPaths()  : array<string|int, mixed>
getPaths
normalizePath()  : string
Normalize a path for insertion in the stack
register()  : void
Register the autoloader with spl_autoload registry
registerPath()  : ModuleAutoloader
registerPath
registerPaths()  : ModuleAutoloader
registerPaths
setModuleClassMap()  : ModuleAutoloader
Sets the class map used to speed up the module autoloading.
setOptions()  : ModuleAutoloader
Configure the autoloader
unregister()  : void
Unregister the autoloader with spl_autoload registry
loadModuleFromDir()  : mixed
loadModuleFromDir
loadModuleFromPhar()  : mixed
loadModuleFromPhar
pharFileToModuleName()  : string
Returns the base module name from the path to a phar

Properties

$explicitPaths

protected array<string|int, mixed> $explicitPaths = []

An array of modulename => path

$moduleClassMap

protected array<string|int, mixed> $moduleClassMap = []

An array of module classes to their containing files

$namespacedPaths

protected array<string|int, mixed> $namespacedPaths = []

An array of namespaceName => namespacePath

$paths

protected array<string|int, mixed> $paths = []

An array of module paths to scan

$pharBasePath

protected string $pharBasePath = ""

Will contain the absolute phar:// path to the executable when packaged as phar file

$pharExtensions

protected array<string|int, mixed> $pharExtensions = []

An array of supported phar extensions (filled on constructor)

Methods

__construct()

Constructor

public __construct([null|array<string|int, mixed>|Traversable $options = null ]) : mixed

Allow configuration of the autoloader via the constructor.

Parameters
$options : null|array<string|int, mixed>|Traversable = null

autoload()

Autoload a class

public autoload(string $class) : mixed
Parameters
$class : string
Return values
mixed

False [if unable to load $class] get_class($class) [if $class is successfully loaded]

getModuleClassMap()

Retrieves the class map for all loaded modules.

public getModuleClassMap() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPaths()

getPaths

public getPaths() : array<string|int, mixed>

This is primarily for unit testing, but could have other uses.

Return values
array<string|int, mixed>

normalizePath()

Normalize a path for insertion in the stack

public static normalizePath(string $path[, bool $trailingSlash = true ]) : string
Parameters
$path : string
$trailingSlash : bool = true

Whether trailing slash should be included

Return values
string

register()

Register the autoloader with spl_autoload registry

public register() : void

registerPath()

registerPath

public registerPath(string $path[, bool|string $moduleName = false ]) : ModuleAutoloader
Parameters
$path : string
$moduleName : bool|string = false
Tags
throws
InvalidArgumentException
Return values
ModuleAutoloader

registerPaths()

registerPaths

public registerPaths(array<string|int, mixed>|Traversable $paths) : ModuleAutoloader
Parameters
$paths : array<string|int, mixed>|Traversable
Tags
throws
InvalidArgumentException
Return values
ModuleAutoloader

setModuleClassMap()

Sets the class map used to speed up the module autoloading.

public setModuleClassMap(array<string|int, mixed> $classmap) : ModuleAutoloader
Parameters
$classmap : array<string|int, mixed>
Return values
ModuleAutoloader

setOptions()

Configure the autoloader

public setOptions(array<string|int, mixed>|Traversable $options) : ModuleAutoloader

In most cases, $options should be either an associative array or Traversable object.

Parameters
$options : array<string|int, mixed>|Traversable
Return values
ModuleAutoloader

unregister()

Unregister the autoloader with spl_autoload registry

public unregister() : void

loadModuleFromDir()

loadModuleFromDir

protected loadModuleFromDir(string $dirPath, string $class) : mixed
Parameters
$dirPath : string
$class : string
Return values
mixed

False [if unable to load $class] get_class($class) [if $class is successfully loaded]

loadModuleFromPhar()

loadModuleFromPhar

protected loadModuleFromPhar(string $pharPath, string $class) : mixed
Parameters
$pharPath : string
$class : string
Return values
mixed

False [if unable to load $class] get_class($class) [if $class is successfully loaded]

pharFileToModuleName()

Returns the base module name from the path to a phar

protected pharFileToModuleName(string $pharPath) : string
Parameters
$pharPath : string
Return values
string

        
On this page

Search results