JLoader
Static class to handle loading of libraries.
package |
Joomla.Platform |
---|---|
since |
1.7.0 |
Methods
_autoload
Autoload a class based on name.
_autoload(string $class) : boolean
since |
1.7.3 |
---|
Arguments
- $class
string
The class to be loaded.
Response
boolean
True if the class was loaded, false otherwise.
_load
Load a class based on name and lookup array.
_load(string $class, array $lookup) : boolean
since |
3.0.0 |
---|
Arguments
- $class
string
The class to be loaded (without prefix).- $lookup
array
The array of base paths to use for finding the class file.
Response
boolean
True if the class was loaded, false otherwise.
applyAliasFor
Applies a class alias for an already loaded class, if a class alias was created for it.
applyAliasFor(string $class) : void
since |
3.4 |
---|
Arguments
- $class
string
We'll look for and register aliases for this (real) class name
discover
Method to discover classes of a given type in a given path.
discover(string $classPrefix, string $parentPath, boolean $force = true, boolean $recurse = false) : void
since |
1.7.0 |
---|
Arguments
- $classPrefix
string
The class name prefix to use for discovery.- $parentPath
string
Full path to the parent folder for the classes to discover.- $force
boolean
True to overwrite the autoload path value for the class if it already exists.- $recurse
boolean
Recurse through all child directories as well as the parent path.
getClassList
Method to get the list of registered classes and their respective file paths for the autoloader.
getClassList() : array
since |
1.7.0 |
---|
Response
array
The array of class => path values for the autoloader.
getDeprecatedAliases
Method to get the list of deprecated class aliases.
getDeprecatedAliases() : array
since |
3.6.3 |
---|
Response
array
An associative array with deprecated class alias data.
getNamespaces
Method to get the list of registered namespaces.
getNamespaces(string $type = 'psr0') : array
since |
3.1.4 |
---|
Arguments
- $type
string
Defines the type of namespace, can be prs0 or psr4.
Response
array
The array of namespace => path values for the autoloader.
import
Loads a class from specified directories.
import(string $key, string $base = null) : boolean
since |
1.7.0 |
---|
Arguments
- $key
string
The class name to look for (dot notation).- $base
string
Search this directory for the class.
Response
boolean
True on success.
load
Load the file for a class.
load(string $class) : boolean
since |
1.7.0 |
---|
Arguments
- $class
string
The class to be loaded.
Response
boolean
True on success
loadAliasFor
Loads the aliases for the given class.
loadAliasFor(string $class) : void
since |
3.8.0 |
---|
Arguments
- $class
string
The class.
loadByAlias
Method to autoload classes that have been aliased using the registerAlias method.
loadByAlias(string $class) : boolean
since |
3.2 |
---|
Arguments
- $class
string
The fully qualified class name to autoload.
Response
boolean
True on success, false otherwise.
loadByPsr0
Method to autoload classes that are namespaced to the PSR-0 standard.
loadByPsr0(string $class) : boolean
since |
3.2.0 |
---|---|
deprecated |
4.0 this method will be removed |
Arguments
- $class
string
The fully qualified class name to autoload.
Response
boolean
True on success, false otherwise.
loadByPsr4
Method to autoload classes that are namespaced to the PSR-4 standard.
loadByPsr4(string $class) : boolean
since |
3.7.0 |
---|
Arguments
- $class
string
The fully qualified class name to autoload.
Response
boolean
True on success, false otherwise.
register
Directly register a class to the autoload list.
register(string $class, string $path, boolean $force = true) : void
since |
1.7.0 |
---|
Arguments
- $class
string
The class name to register.- $path
string
Full path to the file that holds the class to register.- $force
boolean
True to overwrite the autoload path value for the class if it already exists.
registerAlias
Offers the ability for "just in time" usage of class_alias()
.
registerAlias(string $alias, string $original, string|boolean $version = false) : boolean
You cannot overwrite an existing alias.
since |
3.2 |
---|
Arguments
- $alias
string
The alias name to register.- $original
string
The original class to alias.- $version
string|boolean
The version in which the alias will no longer be present.
Response
boolean
True if registration was successful. False if the alias already exists.
registerNamespace
Register a namespace to the autoloader. When loaded, namespace paths are searched in a "last in, first out" order.
registerNamespace(string $namespace, string $path, boolean $reset = false, boolean $prepend = false, string $type = 'psr0') : void
throws |
|
---|---|
note |
The default argument of $type will be changed in J4 to be 'psr4' |
since |
3.1.4 |
Arguments
- $namespace
string
A case sensitive Namespace to register.- $path
string
A case sensitive absolute file path to the library root where classes of the given namespace can be found.- $reset
boolean
True to reset the namespace with only the given lookup path.- $prepend
boolean
If true, push the path to the beginning of the namespace lookup paths array.- $type
string
Defines the type of namespace, can be prs0 or psr4.
registerPrefix
Register a class prefix with lookup path. This will allow developers to register library packages with different class prefixes to the system autoloader. More than one lookup path may be registered for the same class prefix, but if this method is called with the reset flag set to true then any registered lookups for the given prefix will be overwritten with the current lookup path. When loaded, prefix paths are searched in a "last in, first out" order.
registerPrefix(string $prefix, string $path, boolean $reset = false, boolean $prepend = false) : void
throws |
|
---|---|
since |
3.0.0 |
Arguments
- $prefix
string
The class prefix to register.- $path
string
Absolute file path to the library root where classes with the given prefix can be found.- $reset
boolean
True to reset the prefix with only the given lookup path.- $prepend
boolean
If true, push the path to the beginning of the prefix lookup paths array.
setup
Method to setup the autoloaders for the Joomla Platform.
setup(boolean $enablePsr = true, boolean $enablePrefixes = true, boolean $enableClasses = true) : void
Since the SPL autoloaders are called in a queue we will add our explicit class-registration based loader first, then fall back on the autoloader based on conventions. This will allow people to register a class in a specific location and override platform libraries as was previously possible.
since |
3.1.4 |
---|
Arguments
- $enablePsr
boolean
True to enable autoloading based on PSR-0.- $enablePrefixes
boolean
True to enable prefix based class loading (needed to auto load the Joomla core).- $enableClasses
boolean
True to enable class map based class loading (needed to auto load the Joomla core).
stripFirstBackslash
Strips the first backslash from the given class if present.
stripFirstBackslash(string $class) : string
since |
3.8.0 |
---|
Arguments
- $class
string
The class to strip the first prefix from.
Response
string
The striped class name.
Properties
classes
Container for already imported library paths.
since |
1.7.0 |
---|
Type(s)
array
imported
Container for already imported library paths.
since |
1.7.0 |
---|
Type(s)
array
prefixes
Container for registered library class prefixes and path lookups.
since |
3.0.0 |
---|
Type(s)
array
classAliases
Holds proxy classes and the class names the proxy.
since |
3.2 |
---|
Type(s)
array
classAliasesInverse
Holds the inverse lookup for proxy classes and the class names the proxy.
since |
3.4 |
---|
Type(s)
array
namespaces
Container for namespace => path map.
since |
3.1.4 |
---|
Type(s)
array
deprecatedAliases
Holds a reference for all deprecated aliases (mainly for use by a logging platform).
since |
3.6.3 |
---|
Type(s)
array