October\Rain\Support\ClassLoader

Overview

ClassLoader is a custom autoloader used by October CMS, it uses folder names to be lower case and the file name to be capitalized as per the class name.


Public Properties

public October\Rain\Filesystem\Filesystem $files

files instance

public string $basePath

public string|null $manifestPath

public array $manifest

manifest of loaded items

Protected Properties

protected bool $manifestDirty

manifestDirty if manifest needs to be written

protected array $namespaces

namespaces registered

protected array $directories

directories registered

protected bool $registered

registered indicates if this class is registered


Public Methods

public __construct()

public __construct($files, $basePath): void

__construct creates a new package manifest instance

public addDirectories()

public addDirectories(string|array $directories): void 

addDirectories to the class loader

public addNamespace()

public addNamespace($namespace, $directory): void 

public build()

public build(): void 

build the manifest and write it to disk

public getDirectories()

public getDirectories(): array 

getDirectories registered with the loader

public initManifest()

public initManifest($manifestPath): void 

initManifest starts the manifest cache file after registration.

public load()

public load(string $class): bool 

load the given class file

public register()

public register(): void 

register the given class loader on the auto-loader stack

public removeDirectories()

public removeDirectories(string|array $directories = null): void

removeDirectories from the class loader

Protected Methods

protected ensureManifestIsLoaded()

protected ensureManifestIsLoaded(): void 

ensureManifestIsLoaded has been loaded into memory

protected includeClass()

protected includeClass($class, $path): void 

includeClass and add to the manifest

protected isRealFilePath()

protected isRealFilePath($path): bool 

isRealFilePath determines if a relative path to a file exists and is real

protected loadUpperOrLower()

protected loadUpperOrLower($class, $directory, $upperClass, $lowerClass): bool 

loadUpperOrLower loads a class in a directory with the supplied upper and lower class path.

protected normalizeClass()

protected normalizeClass($class): array 

normalizeClass get the normal file name for a class

protected write()

protected write($manifest): void 

write the given manifest array to disk