final class ClassAutoloader (View source)

Constants

private FLAG_NONE

private FLAG_MODIFIED_PSR4

private MODIFIED_PSR4_SEGMENTS

Properties

static private ClassAutoloader|null $instance

The singleton ClassAutoloader instance.

private bool $hooked

Is this instance in the autoload queue?

private string $coreDir

The absolute path to the core directory, always using '/' as directory separator and ending with '/'.

private string $coreStartingPointDir

The absolute path to the core starting point directory, always using '/' as directory separator and ending with '/'.

private string $applicationNamespace

The application namespace, with a trailing '\' and without a leading '\' (or an empty string if no namespace).

private string $applicationDir

The absolute path to the application directory, always using '/' as directory separator and ending with '/'.

private string $applicationStartingPointDir

The absolute path to the application starting point directory, always using '/' as directory separator and ending with '/'.

private bool $applicationLegacyNamespaceEnabled

Should we enable loading classes in the Application\Src namespace from the /application/src folder?

private string $packagesDir

The absolute path to the packages directory, always using '/' as directory separator and ending with '/'.

private array $aliases

Array keys are the aliases (without a leading '\'), array values are the actual classes (without a leading '\').

private string[] $requiredAliases

List of class aliases that must be autoloaded at boot time (without leading '\').

private Package[]|null[] $registeredPackages

List of registered packages.

private array[] $packageInfo

Details about the computed autoloading stuff for every package.

Methods

__construct()

No description

reset(bool $aliasesToo = false, bool $packagesToo = false)

Reset this instance values to the default ones.

static ClassAutoloader
getInstance()

Get the singleton ClassAutoloader instance.

hook(bool $prepend = false)

Ensure that this instance is in the autoload queue.

unhook()

Remove this instance from the autoload queue.

bool
isHooked()

Is this instance in the autoload queue?

setCoreDir(string $value)

Set the absolute path to the core directory.

string
getCoreDir()

Get the absolute path to the core directory, always using '/' as directory separator and ending with '/'.

setCoreStartingPointDir(string $value)

Set the absolute path to the core starting point directory.

string
getCoreStartingPointDir()

Get the absolute path to the core starting point directory, always using '/' as directory separator and ending with '/'.

setApplicationNamespace(string $value)

Set the application namespace.

string
getApplicationNamespace()

Get the application namespace, with a trailing '\' and without a leading '\' (or an empty string if no namespace).

setApplicationDir(string $value)

Set the absolute path to the application directory.

string
getApplicationDir()

Get the absolute path to the application directory, always using '/' as directory separator and ending with '/'.

setApplicationStartingPointDir(string $value)

Set the absolute path to the application starting point directory.

string
getApplicationStartingPointDir()

Get the absolute path to the application starting point directory, always using '/' as directory separator and ending with '/'.

setApplicationLegacyNamespaceEnabled(bool $value)

Should we enable loading classes in the Application\Src namespace from the /application/src folder?

bool
isApplicationLegacyNamespaceEnabled()

Should we enable loading classes in the Application\Src namespace from the /application/src folder?

setPackagesDir(string $value)

Set the absolute path to the packages directory.

string
getPackagesDir()

Ghe absolute path to the packages directory, always using '/' as directory separator and ending with '/'.

registerPackageHandle(string $packageHandle)

Register a package (given its handle).

registerPackageController(Package $packageController)

Register a package (given its controller).

unregisterPackage(string $packageHandle)

Unregister a package (given its handle).

addClassAlias(string $alias, string $actual, bool $requiredAtBoot = false)

Add a class alias.

addClassAliases(array $aliases, bool $requiredAtBoot = false)

Add multiple class aliases.

array
getClassAliases()

Get the registered class aliases.

string[]
getRequiredAliases()

Get the of class aliases that must be autoloaded at boot time (without leading '\').

autoloadAliasesAtBoot()

Load the class aliases that must be autoloaded at boot time.

bool
loadClass(string $class)

No description

bool
loadClassFromCore(string $class)

No description

bool
loadClassFromPackages(string $class)

No description

bool
loadClassFromApplication(string $class)

No description

bool
loadClassFromAliases(string $class)

No description

bool
loadLegacyClass(string $class)

No description

listPackagesInfo(string $class)

No description

listStandardPackageInfo(string $class, string $packageHandle)

No description

array
listCustomPackageInfo(string $packageHandle)

No description

bool
loadPSR4Class(string $class, string $namespacePrefix, string $directoryPrefix, int $flags = self::FLAG_NONE)

No description

string
findPSR4Class(string $class, string $namespacePrefix, string $directoryPrefix, int $flags)

No description

Details

__construct()

No description

ClassAutoloader reset(bool $aliasesToo = false, bool $packagesToo = false)

Reset this instance values to the default ones.

Parameters

bool $aliasesToo

should we reset the aliases too?

bool $packagesToo

should we reset the registered packages too?

Return Value

ClassAutoloader

static ClassAutoloader getInstance()

Get the singleton ClassAutoloader instance.

Return Value

ClassAutoloader

ClassAutoloader hook(bool $prepend = false)

Ensure that this instance is in the autoload queue.

Parameters

bool $prepend

Return Value

ClassAutoloader

ClassAutoloader unhook()

Remove this instance from the autoload queue.

Return Value

ClassAutoloader

bool isHooked()

Is this instance in the autoload queue?

Return Value

bool

ClassAutoloader setCoreDir(string $value)

Set the absolute path to the core directory.

Parameters

string $value

Return Value

ClassAutoloader

Examples

'/webroot/concrete'
'C:\\webroot\\concrete'

string getCoreDir()

Get the absolute path to the core directory, always using '/' as directory separator and ending with '/'.

Return Value

string

Examples

'/webroot/concrete/'
'C:/webroot/concrete/'

ClassAutoloader setCoreStartingPointDir(string $value)

Set the absolute path to the core starting point directory.

Parameters

string $value

Return Value

ClassAutoloader

Examples

'/webroot/concrete/config/install/packages'
'C:\\webroot\\concrete\\config\\install\\packages'

string getCoreStartingPointDir()

Get the absolute path to the core starting point directory, always using '/' as directory separator and ending with '/'.

Return Value

string

Examples

'/webroot/concrete/config/install/packages/'
'C:/webroot/concrete/config/install/packages/'

ClassAutoloader setApplicationNamespace(string $value)

Set the application namespace.

Parameters

string $value

Return Value

ClassAutoloader

Examples

'Application'

string getApplicationNamespace()

Get the application namespace, with a trailing '\' and without a leading '\' (or an empty string if no namespace).

Return Value

string

Examples

'Application\\'

ClassAutoloader setApplicationDir(string $value)

Set the absolute path to the application directory.

Parameters

string $value

Return Value

ClassAutoloader

Examples

'/webroot/application'
'C:\\webroot\\application'

string getApplicationDir()

Get the absolute path to the application directory, always using '/' as directory separator and ending with '/'.

Return Value

string

Examples

'/webroot/application/'
'C:/webroot/application/'

ClassAutoloader setApplicationStartingPointDir(string $value)

Set the absolute path to the application starting point directory.

Parameters

string $value

Return Value

ClassAutoloader

Examples

'/webroot/application/config/install/packages'
'C:\\webroot\\application\\config\\install\\packages'

string getApplicationStartingPointDir()

Get the absolute path to the application starting point directory, always using '/' as directory separator and ending with '/'.

Return Value

string

Examples

'/webroot/application/config/install/packages/'
'C:/webroot/application/config/install/packages/'

ClassAutoloader setApplicationLegacyNamespaceEnabled(bool $value)

Should we enable loading classes in the Application\Src namespace from the /application/src folder?

Parameters

bool $value

Return Value

ClassAutoloader

bool isApplicationLegacyNamespaceEnabled()

Should we enable loading classes in the Application\Src namespace from the /application/src folder?

Return Value

bool

ClassAutoloader setPackagesDir(string $value)

Set the absolute path to the packages directory.

Parameters

string $value

Return Value

ClassAutoloader

Examples

'/webroot/packages'
'C:\\webroot\\packages'

string getPackagesDir()

Ghe absolute path to the packages directory, always using '/' as directory separator and ending with '/'.

Return Value

string

Examples

'/webroot/packages/'
'C:/webroot/packages/'

ClassAutoloader registerPackageHandle(string $packageHandle)

Register a package (given its handle).

Parameters

string $packageHandle

Return Value

ClassAutoloader

ClassAutoloader registerPackageController(Package $packageController)

Register a package (given its controller).

Parameters

Package $packageController

Return Value

ClassAutoloader

ClassAutoloader unregisterPackage(string $packageHandle)

Unregister a package (given its handle).

Parameters

string $packageHandle

Return Value

ClassAutoloader

ClassAutoloader addClassAlias(string $alias, string $actual, bool $requiredAtBoot = false)

Add a class alias.

Parameters

string $alias
string $actual
bool $requiredAtBoot

Return Value

ClassAutoloader

ClassAutoloader addClassAliases(array $aliases, bool $requiredAtBoot = false)

Add multiple class aliases.

Parameters

array $aliases
bool $requiredAtBoot

Return Value

ClassAutoloader

array getClassAliases()

Get the registered class aliases.

Return Value

array

array keys are the aliases (without a leading '\'), array values are the actual classes (without a leading '\')

string[] getRequiredAliases()

Get the of class aliases that must be autoloaded at boot time (without leading '\').

Return Value

string[]

ClassAutoloader autoloadAliasesAtBoot()

Load the class aliases that must be autoloaded at boot time.

Return Value

ClassAutoloader

bool loadClass(string $class)

No description

Parameters

string $class

the FQN name of the class (must not start with '\')

Return Value

bool

private bool loadClassFromCore(string $class)

No description

Parameters

string $class

the FQN name of the class (must not start with '\')

Return Value

bool

private bool loadClassFromPackages(string $class)

No description

Parameters

string $class

the FQN name of the class (must not start with '\')

Return Value

bool

private bool loadClassFromApplication(string $class)

No description

Parameters

string $class

the FQN name of the class (must not start with '\')

Return Value

bool

private bool loadClassFromAliases(string $class)

No description

Parameters

string $class

the FQN name of the class (must not start with '\')

Return Value

bool

private bool loadLegacyClass(string $class)

No description

Parameters

string $class

the FQN name of the class (must not start with '\')

Return Value

bool

private Generator listPackagesInfo(string $class)

No description

Parameters

string $class

the FQN name of the class (must not start with '\')

Return Value

Generator

private Generator listStandardPackageInfo(string $class, string $packageHandle)

No description

Parameters

string $class

the FQN name of the class (must not start with '\')

string $packageHandle

Return Value

Generator

private array listCustomPackageInfo(string $packageHandle)

No description

Parameters

string $packageHandle

Return Value

array

private bool loadPSR4Class(string $class, string $namespacePrefix, string $directoryPrefix, int $flags = self::FLAG_NONE)

No description

Parameters

string $class

the FQN name of the class (must not start with '\')

string $namespacePrefix

the namespace prefix (must end with '\')

string $directoryPrefix

the path of the base directory (must end with '/')

int $flags

Return Value

bool

private string findPSR4Class(string $class, string $namespacePrefix, string $directoryPrefix, int $flags)

No description

Parameters

string $class

the FQN name of the class (must not start with '\')

string $namespacePrefix

the namespace prefix (must end with '\')

string $directoryPrefix

the path of the base directory (must end with '/')

int $flags

Return Value

string

empty string if not found