Documentation

ClassLoader

Cloudrexx ClassLoader

Tags
copyright

CLOUDREXX CMS - CLOUDREXX AG

author

CLOUDREXX Development Team info@cloudrexx.com

subpackage

core_classloader

Table of Contents

Constants

CLASSMAP_CACHE_KEY  = 'ClassMap'

Properties

$classMap  : array<string|int, mixed>
List of loaded classes and their path in the file system
$usercache  : mixed
$basePath  : mixed
$customizingPath  : mixed
$cx  : mixed
$legacyClassLoader  : mixed

Methods

__construct()  : mixed
To use LegacyClassLoader config.php and set_constants.php must be loaded If they are not present, set $useLegacyAsFallback to false!
autoload()  : type
This needs to be public because Doctrine tries to load a class using all registered autoloaders.
classExists()  : bool
Tests if a class is available. You may specify if legacy and customizing can be used to load it if necessary.
flushCache()  : mixed
Flushes cached entries from usercache
getFileFromCustomizing()  : mixed
Checks if a customized version of a file exists in the customizing folder and returns its path if it exists.
getFileFromMediaSource()  : mixed
Get file path with filename from registered MediaSource filesystems.
getFileFromTheme()  : mixed
Checks if a customized version of a file exists is the currently loaded design theme and returns its path if it exists.
getFileFromWebsiteRepository()  : mixed
Checks if a customized version of a file exists in the website data repository and returns its path if it exists.
getFilePath()  : mixed
Get the path to a customized version of a file
getWebFilePath()  : mixed
Shortcut for {@see getFilePath()} with argument $webPath set to TRUE
loadFile()  : bool
Try to load the file specified by $path
loadClassFromClassMapCache()  : bool
Try to load a PHP class from cache.
load()  : mixed
loadLegacy()  : mixed

Constants

Properties

$classMap

List of loaded classes and their path in the file system

protected array<string|int, mixed> $classMap = array()

Methods

__construct()

To use LegacyClassLoader config.php and set_constants.php must be loaded If they are not present, set $useLegacyAsFallback to false!

public __construct(mixed $cx[, bool $useLegacyAsFallback = true ][, mixed $customizingPath = null ][, mixed $usercache = null ]) : mixed
Parameters
$cx : mixed
$useLegacyAsFallback : bool = true

(optional) Wheter to use LegacyClassLoader too (default) or not

$customizingPath : mixed = null
$usercache : mixed = null

autoload()

This needs to be public because Doctrine tries to load a class using all registered autoloaders.

public autoload(type $name) : type
Parameters
$name : type
Return values
type

void

classExists()

Tests if a class is available. You may specify if legacy and customizing can be used to load it if necessary.

public classExists(string $class[, bool $useLegacy = false ][, bool $useCustomizing = true ]) : bool
Parameters
$class : string

Class name to look for

$useLegacy : bool = false

(optional) Wheter to allow usage of legacy class loader or not (default false)

$useCustomizing : bool = true

(optional) Wheter to allow usage of customizings or not (default true)

Tags
todo

$useCustomizing does not work correctly if legacy is enabled

Return values
bool

True if class could be found using the allowed methods, false otherwise

flushCache()

Flushes cached entries from usercache

public flushCache() : mixed

This does not drop the cache files!

getFileFromCustomizing()

Checks if a customized version of a file exists in the customizing folder and returns its path if it exists.

public getFileFromCustomizing(string $file[, bool $webPath = false ][, bool &$isCustomized = false ]) : mixed
Parameters
$file : string

Path of file to look for a customized version for.

$webPath : bool = false

Whether or not to return the relative web path instead of the absolute file system path (default).

$isCustomized : bool = false

If $isCustomized is provided, then it is set to TRUE if a customized version of the file does exist. Otherwise it is set to FALSE.

Return values
mixed

Path (as string) to customized version of file or FALSE if none exists.

getFileFromMediaSource()

Get file path with filename from registered MediaSource filesystems.

public getFileFromMediaSource(string $file[, bool $webPath = false ]) : mixed
Parameters
$file : string

Path of file, it should be located in /images, /media or /themes.

$webPath : bool = false

Whether or not to return the absolute file path or MediaSource file system path.

Return values
mixed

Returns absolute file path or MediaSource file path or FALSE if none exists.

getFileFromTheme()

Checks if a customized version of a file exists is the currently loaded design theme and returns its path if it exists.

public getFileFromTheme(string $file[, bool $webPath = false ][, Theme $theme = null ]) : mixed
Parameters
$file : string

Path of file to look for a customized version for.

$webPath : bool = false

Whether or not to return the relative web path instead of the absolute file system path (default).

$theme : Theme = null

(optional) Theme to get file from. Defaults to current theme (if set)

Return values
mixed

Path (as string) to customized version of file or FALSE if none exists.

getFileFromWebsiteRepository()

Checks if a customized version of a file exists in the website data repository and returns its path if it exists.

public getFileFromWebsiteRepository(string $file[, bool $webPath = false ][, bool &$isWebsite = false ]) : mixed
Parameters
$file : string

Path of file to look for a customized version for.

$webPath : bool = false

Whether or not to return the relative web path instead of the absolute file system path (default).

$isWebsite : bool = false

If $isWebsite is provided, then it is set to TRUE if the file can be located in the website data repository. Otherwise it is set to FALSE.

Return values
mixed

Path (as string) to customized version of file or FALSE if none exists.

getFilePath()

Get the path to a customized version of a file

public getFilePath(string $file[, bool &$isCustomized = false ][, bool &$isWebsite = false ][, bool $webPath = false ][, Theme $theme = null ]) : mixed

The detection algorithm for a customized version uses the follow precedence:

  1. If we are in FRONTEND mode and the file is part of the 'view' layer (it is located within the 'View' folder of its component), then it will return the path to the customized version of the file in the currently active design theme (if it does exist at all). Note that the folder 'View' is being left out in the design theme as only files of the 'View' folder can be loaded from the design theme. I.e.: /themes/default/core_modules/Media/Media/Pdf.svg

  2. If a customized version exists in the /customizing folder, then the path to that one will be returned. I.e.: /customizing/core_modules/Media/View/Media/Pdf.svg

  3. If a customized version exists in the website data repository, then that one will be returned. I.e.: /websites/demo/core_modules/Media/View/Media/Pdf.svg

  4. Ensure that the original version of the file exists at least (within the code base repository) and return that one. I.e.: /core_modules/Media/View/Media/Pdf.svg

Parameters
$file : string

The file to return the path from.

$isCustomized : bool = false

If $isCustomized is provided, then it is set to TRUE if a customized version of the file does exist. Otherwise it is set to FALSE.

$isWebsite : bool = false

If $isWebsite is provided, then it is set to TRUE if the file can be located in the website data repository. Otherwise it is set to FALSE.

$webPath : bool = false

Whether or not to return the absolute file system path of the customized file. IMPORTANT: This will cause the algorithm to cut of any URL arguments from the file path like '?foo=bar' or '#foo', to be able to successfully locate dynamic media ressources. Therefore, if the filename or path of $file contains the character '?' or '#', then the result of this method is unknown.

$theme : Theme = null

(optional) Theme to get file from. Defaults to current theme (if set)

Return values
mixed

Returns the path (either absolute file system path or relativ web path, based on $webPath) to a customized version of the file identified by $file. If no customized version of the file does exist, then FALSE is being returned.

getWebFilePath()

Shortcut for {@see getFilePath()} with argument $webPath set to TRUE

public getWebFilePath(mixed $file[, mixed &$isCustomized = false ][, mixed &$isWebsite = false ]) : mixed
Parameters
$file : mixed
$isCustomized : mixed = false
$isWebsite : mixed = false

loadFile()

Try to load the file specified by $path

public loadFile(mixed $path[, mixed $name = '' ]) : bool
Parameters
$path : mixed

string Path to the file to be loaded

$name : mixed = ''

string Optional filename of the file to be loaded. If provided, the path of the file will be cached, so that the next time the file will be requested by the autoloading functionality of PHP, it can be loaded way faster.

Return values
bool

TRUE, if file was loaded. Otherwise FALSE, if file could not be located.

loadClassFromClassMapCache()

Try to load a PHP class from cache.

protected loadClassFromClassMapCache(mixed $name) : bool
Parameters
$name : mixed

string The name of the class to be loaded

Return values
bool

TRUE if the class specified by $name was loaded from cache. Otherwise FALSE

load()

private load(mixed $name, mixed &$resolvedPath) : mixed
Parameters
$name : mixed
$resolvedPath : mixed

loadLegacy()

private loadLegacy(mixed $name) : mixed
Parameters
$name : mixed

        
On this page

Search results