TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Core\Core\ClassLoader Class Reference
Inheritance diagram for TYPO3\CMS\Core\Core\ClassLoader:
t3lib_autoloader

Public Member Functions

 __construct (ApplicationContext $context)
 
 injectClassAliasMap (ClassAliasMap $classAliasMap)
 
 injectCoreCache (Cache\Frontend\PhpFrontend $coreCache)
 
 injectClassesCache (Cache\Frontend\StringFrontend $classesCache)
 
 loadClass ($className)
 
 getClassLoadingInformationFromCache ($cacheEntryIdentifier)
 
 buildClassLoadingInformation ($className)
 
 setCacheIdentifier ($cacheIdentifier)
 
 setPackages (array $packages)
 
 addActivePackage (\TYPO3\Flow\Package\PackageInterface $package)
 
 setRuntimeClassLoadingInformationFromAutoloadRegistry (array $classFileAutoloadRegistry)
 
 setAliasForClassName ($aliasClassName, $originalClassName)
 
 checkForCrashAndCleanup ()
 

Static Public Member Functions

static getClassNameForAlias ($alias)
 
static getAliasForClassName ($className)
 
static getAliasesForClassName ($className)
 

Public Attributes

const VALID_CLASSNAME_PATTERN = '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9\\\\_\x7f-\xff]*$/'
 

Protected Member Functions

 buildCachedClassLoadingInformation ($cacheEntryIdentifier, $className)
 
 isValidClassName ($className)
 
 buildClassLoadingInformationForClassFromCorePackage ($className)
 
 fetchClassLoadingInformationFromRuntimeCache ($className)
 
 buildClassLoadingInformationForClassFromRegisteredPackages ($className)
 
 buildClassLoadingInformationForClassByNamingConvention ($className)
 
 getCacheEntryIdentifier ()
 
 buildPackageNamespacesAndClassesPaths ()
 
 buildPackageNamespaceAndClassesPath (\TYPO3\Flow\Package\PackageInterface $package)
 
 loadPackageNamespacesFromCache ()
 
 buildPackageNamespace (\TYPO3\Flow\Package\PackageInterface $package)
 
 loadClassFilesFromAutoloadRegistryIntoRuntimeClassInformationCache (array $packages)
 
 transferRuntimeClassInformationCacheEntriesToClassesCache ()
 
 buildPackageClassPathsForLegacyExtension (PackageInterface $package)
 
 savePackageNamespacesAndClassesPathsToCache ()
 
 sortPackageNamespaces ()
 
 acquireLock ()
 
 releaseLock ($needRelease)
 
 clearClassesCache ()
 
 getLocker ()
 

Protected Attributes

 $context
 
 $classAliasMap
 
 $classesCache
 
 $coreCache
 
 $cacheIdentifier
 
 $packages = array()
 
 $isEarlyCache = TRUE
 
 $runtimeClassLoadingInformationCache = array()
 
 $packageNamespaces = array()
 
 $packageClassesPaths = array()
 
 $isLoadingLocker = FALSE
 
 $lockObject = NULL
 
 $shutdownRegistered = FALSE
 

Static Protected Attributes

static $staticAliasMap
 

Detailed Description

Class Loader implementation which loads .php files found in the classes directory of an object.

Definition at line 26 of file ClassLoader.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Core\ClassLoader::__construct ( ApplicationContext  $context)

Constructor

Parameters
ApplicationContext$context

Definition at line 113 of file ClassLoader.php.

References TYPO3\CMS\Core\Core\ClassLoader\$context.

Member Function Documentation

◆ acquireLock()

TYPO3\CMS\Core\Core\ClassLoader::acquireLock ( )
protected

Acquires a lock for the cache if we didn't already lock before.

Returns
bool TRUE if the cache was acquired by this call and needs to be released
Exceptions

Definition at line 748 of file ClassLoader.php.

References TYPO3\CMS\Core\Core\ClassLoader\$lockObject, and TYPO3\CMS\Core\Core\ClassLoader\getLocker().

Referenced by TYPO3\CMS\Core\Core\ClassLoader\buildCachedClassLoadingInformation(), and TYPO3\CMS\Core\Core\ClassLoader\buildPackageNamespacesAndClassesPaths().

◆ addActivePackage()

TYPO3\CMS\Core\Core\ClassLoader::addActivePackage ( \TYPO3\Flow\Package\PackageInterface  $package)

Add a package to class loader just during runtime, so classes can be loaded without the need for a new request

Parameters
\TYPO3\Flow\Package\PackageInterface$package
Returns
ClassLoader

Definition at line 501 of file ClassLoader.php.

References TYPO3\CMS\Core\Core\ClassLoader\buildPackageNamespaceAndClassesPath(), TYPO3\CMS\Core\Core\ClassLoader\loadClassFilesFromAutoloadRegistryIntoRuntimeClassInformationCache(), and TYPO3\CMS\Core\Core\ClassLoader\sortPackageNamespaces().

◆ buildCachedClassLoadingInformation()

TYPO3\CMS\Core\Core\ClassLoader::buildCachedClassLoadingInformation (   $cacheEntryIdentifier,
  $className 
)
protected

Builds the class loading information and writes it to the cache. It handles Locking for this cache.

Caution: The function loadClass can be called "recursively" by spl_autoloader. This needs to be observed when locking for cache access. Only the first call to loadClass may acquire and release the lock!

Parameters
string$cacheEntryIdentifierCache identifier for this class
string$classNameName of class this information is for
Returns
array|FALSE The class information, empty array if class is unkown or FALSE if class information was not found in cache.

Definition at line 243 of file ClassLoader.php.

References TYPO3\CMS\Core\Core\ClassLoader\acquireLock(), TYPO3\CMS\Core\Core\ClassLoader\buildClassLoadingInformation(), TYPO3\CMS\Core\Core\ClassLoader\getClassLoadingInformationFromCache(), and TYPO3\CMS\Core\Core\ClassLoader\releaseLock().

Referenced by TYPO3\CMS\Core\Core\ClassLoader\loadClass().

◆ buildClassLoadingInformation()

◆ buildClassLoadingInformationForClassByNamingConvention()

TYPO3\CMS\Core\Core\ClassLoader::buildClassLoadingInformationForClassByNamingConvention (   $className)
protected

Retrieve class loading information based on 'extbase' naming convention into the registry.

Parameters
string$classNameClass name to find source file of
Returns
array|FALSE

Definition at line 406 of file ClassLoader.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\camelCaseToLowerCaseUnderscored().

Referenced by TYPO3\CMS\Core\Core\ClassLoader\buildClassLoadingInformation().

◆ buildClassLoadingInformationForClassFromCorePackage()

TYPO3\CMS\Core\Core\ClassLoader::buildClassLoadingInformationForClassFromCorePackage (   $className)
protected

Retrieve class loading information for class from core package

Parameters
string$className
Returns
array|FALSE

Definition at line 337 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\buildClassLoadingInformation().

◆ buildClassLoadingInformationForClassFromRegisteredPackages()

TYPO3\CMS\Core\Core\ClassLoader::buildClassLoadingInformationForClassFromRegisteredPackages (   $className)
protected

Retrieve class loading information from registered packages

Parameters
string$className
Returns
array|FALSE

Definition at line 369 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\buildClassLoadingInformation().

◆ buildPackageClassPathsForLegacyExtension()

TYPO3\CMS\Core\Core\ClassLoader::buildPackageClassPathsForLegacyExtension ( PackageInterface  $package)
protected

◆ buildPackageNamespace()

TYPO3\CMS\Core\Core\ClassLoader::buildPackageNamespace ( \TYPO3\Flow\Package\PackageInterface  $package)
protected

Extracts the namespace from a package

Parameters
\TYPO3\Flow\Package\PackageInterface$package
Returns
void

Definition at line 590 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\buildPackageNamespaceAndClassesPath().

◆ buildPackageNamespaceAndClassesPath()

TYPO3\CMS\Core\Core\ClassLoader::buildPackageNamespaceAndClassesPath ( \TYPO3\Flow\Package\PackageInterface  $package)
protected

Builds the namespace and class paths for a single package

Parameters
\TYPO3\Flow\Package\PackageInterface$package
Returns
void

Definition at line 553 of file ClassLoader.php.

References TYPO3\CMS\Core\Core\ClassLoader\buildPackageClassPathsForLegacyExtension(), and TYPO3\CMS\Core\Core\ClassLoader\buildPackageNamespace().

Referenced by TYPO3\CMS\Core\Core\ClassLoader\addActivePackage(), and TYPO3\CMS\Core\Core\ClassLoader\buildPackageNamespacesAndClassesPaths().

◆ buildPackageNamespacesAndClassesPaths()

◆ checkForCrashAndCleanup()

TYPO3\CMS\Core\Core\ClassLoader::checkForCrashAndCleanup ( )

Clean the cache and release lock

If building the cache for classes failed, we don't know in which state we are. So we need to clear the cache completely and remove the lock which should exist. If the PHP process receives either the SIGTERM or SIGKILL signal, this function will NOT be called. It might still be called on a SIGSEGV signal though, but we can't trust the members of this class then, hence, the contents of $this->* might be nonsense and its usage might lead to undesired behavior.

This function needs to be public, so it can be called as shutdown-function, but this function may be changed, renamed or deleted without deprecation, also in bugfix-releases.

Returns
void

Definition at line 790 of file ClassLoader.php.

References TYPO3\CMS\Core\Core\ClassLoader\clearClassesCache(), and TYPO3\CMS\Core\Core\ClassLoader\releaseLock().

◆ clearClassesCache()

TYPO3\CMS\Core\Core\ClassLoader::clearClassesCache ( )
protected

Cleares the complete cache for class loader.

Returns
void

Definition at line 822 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\buildPackageNamespacesAndClassesPaths(), and TYPO3\CMS\Core\Core\ClassLoader\checkForCrashAndCleanup().

◆ fetchClassLoadingInformationFromRuntimeCache()

TYPO3\CMS\Core\Core\ClassLoader::fetchClassLoadingInformationFromRuntimeCache (   $className)
protected

Retrieve class loading information from early class name autoload registry cache

Parameters
string$className
Returns
array|FALSE

Definition at line 354 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\buildClassLoadingInformation().

◆ getAliasesForClassName()

static TYPO3\CMS\Core\Core\ClassLoader::getAliasesForClassName (   $className)
static

Get an aliases for a class name

Parameters
string$className
Returns
mixed

Definition at line 738 of file ClassLoader.php.

◆ getAliasForClassName()

static TYPO3\CMS\Core\Core\ClassLoader::getAliasForClassName (   $className)
static

Get alias for class name

Parameters
string$className
Returns
mixed
Deprecated:
since 6.2, will be removed 2 versions later - use getAliasesForClassName() instead

Definition at line 726 of file ClassLoader.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\logDeprecatedFunction().

◆ getCacheEntryIdentifier()

TYPO3\CMS\Core\Core\ClassLoader::getCacheEntryIdentifier ( )
protected

Get cache entry identifier for the package namespaces cache

Returns
string|NULL identifier

Definition at line 459 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\loadPackageNamespacesFromCache(), and TYPO3\CMS\Core\Core\ClassLoader\savePackageNamespacesAndClassesPathsToCache().

◆ getClassLoadingInformationFromCache()

TYPO3\CMS\Core\Core\ClassLoader::getClassLoadingInformationFromCache (   $cacheEntryIdentifier)

Get class loading information for the given identifier for cache Return values:

  • array with class information (empty if the class is invalid)
  • FALSE if no class information is found in cache (cache miss)
  • NULL if the cache identifier is invalid (cache failure)
Parameters
string$cacheEntryIdentifierThe identifier to fetch entry from cache
Returns
array|FALSE The class information, empty array if class is unkown or FALSE if class information was not found in cache.

Definition at line 219 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\buildCachedClassLoadingInformation(), and TYPO3\CMS\Core\Core\ClassLoader\loadClass().

◆ getClassNameForAlias()

◆ getLocker()

TYPO3\CMS\Core\Core\ClassLoader::getLocker ( )
protected

◆ injectClassAliasMap()

TYPO3\CMS\Core\Core\ClassLoader::injectClassAliasMap ( ClassAliasMap  $classAliasMap)

Get class alias map list injected

Parameters
ClassAliasMap
Returns
void

Definition at line 124 of file ClassLoader.php.

References TYPO3\CMS\Core\Core\ClassLoader\$classAliasMap.

◆ injectClassesCache()

TYPO3\CMS\Core\Core\ClassLoader::injectClassesCache ( Cache\Frontend\StringFrontend  $classesCache)

Get classes cache injected

Parameters
\TYPO3\CMS\Core\Cache\Frontend\StringFrontend$classesCache
Returns
void

Definition at line 146 of file ClassLoader.php.

References TYPO3\CMS\Core\Core\ClassLoader\$classesCache.

◆ injectCoreCache()

TYPO3\CMS\Core\Core\ClassLoader::injectCoreCache ( Cache\Frontend\PhpFrontend  $coreCache)

Get core cache injected

Parameters
\TYPO3\CMS\Core\Cache\Frontend\PhpFrontend$coreCache
Returns
void

Definition at line 135 of file ClassLoader.php.

References TYPO3\CMS\Core\Core\ClassLoader\$coreCache.

◆ isValidClassName()

TYPO3\CMS\Core\Core\ClassLoader::isValidClassName (   $className)
protected

Find out if a class name is valid

Parameters
string$className
Returns
bool

Definition at line 327 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\loadClass().

◆ loadClass()

TYPO3\CMS\Core\Core\ClassLoader::loadClass (   $className)

Loads php files containing classes or interfaces found in the classes directory of a package and specifically registered classes.

Caution: This function may be called "recursively" by the spl_autoloader if a class depends on another classes.

Parameters
string$classNameName of the class/interface to load
Returns
bool

Definition at line 169 of file ClassLoader.php.

References TYPO3\CMS\Core\Core\ClassLoader\buildCachedClassLoadingInformation(), TYPO3\CMS\Core\Core\ClassLoader\getClassLoadingInformationFromCache(), TYPO3\CMS\Core\Core\ClassLoader\isValidClassName(), and TYPO3\CMS\Core\Core\ClassLoader\setAliasForClassName().

◆ loadClassFilesFromAutoloadRegistryIntoRuntimeClassInformationCache()

TYPO3\CMS\Core\Core\ClassLoader::loadClassFilesFromAutoloadRegistryIntoRuntimeClassInformationCache ( array  $packages)
protected

◆ loadPackageNamespacesFromCache()

TYPO3\CMS\Core\Core\ClassLoader::loadPackageNamespacesFromCache ( )
protected

◆ releaseLock()

TYPO3\CMS\Core\Core\ClassLoader::releaseLock (   $needRelease)
protected

◆ savePackageNamespacesAndClassesPathsToCache()

TYPO3\CMS\Core\Core\ClassLoader::savePackageNamespacesAndClassesPathsToCache ( )
protected

Save package namespaces and classes paths to cache

Returns
void

Definition at line 658 of file ClassLoader.php.

References TYPO3\CMS\Core\Core\ClassLoader\getCacheEntryIdentifier().

Referenced by TYPO3\CMS\Core\Core\ClassLoader\buildPackageNamespacesAndClassesPaths().

◆ setAliasForClassName()

TYPO3\CMS\Core\Core\ClassLoader::setAliasForClassName (   $aliasClassName,
  $originalClassName 
)

Set alias for class name

Parameters
string$aliasClassName
string$originalClassName
Returns
bool

Definition at line 705 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\loadClass().

◆ setCacheIdentifier()

TYPO3\CMS\Core\Core\ClassLoader::setCacheIdentifier (   $cacheIdentifier)

Set cache identifier

Parameters
string$cacheIdentifierCache identifier for package namespaces cache
Returns
ClassLoader

Definition at line 471 of file ClassLoader.php.

References TYPO3\CMS\Core\Core\ClassLoader\$cacheIdentifier.

◆ setPackages()

TYPO3\CMS\Core\Core\ClassLoader::setPackages ( array  $packages)

◆ setRuntimeClassLoadingInformationFromAutoloadRegistry()

TYPO3\CMS\Core\Core\ClassLoader::setRuntimeClassLoadingInformationFromAutoloadRegistry ( array  $classFileAutoloadRegistry)

This method is necessary for the early loading of the cores autoload registry

Parameters
array$classFileAutoloadRegistry
Returns
void

Definition at line 689 of file ClassLoader.php.

◆ sortPackageNamespaces()

TYPO3\CMS\Core\Core\ClassLoader::sortPackageNamespaces ( )
protected

Sorts longer package namespaces first, to find specific matches before generic ones

Returns
void

Definition at line 673 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\addActivePackage(), and TYPO3\CMS\Core\Core\ClassLoader\buildPackageNamespacesAndClassesPaths().

◆ transferRuntimeClassInformationCacheEntriesToClassesCache()

TYPO3\CMS\Core\Core\ClassLoader::transferRuntimeClassInformationCacheEntriesToClassesCache ( )
protected

Transfers all entries from the early class information cache to the classes cache in order to make them persistent

Returns
void

Definition at line 633 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\buildPackageNamespacesAndClassesPaths().

Member Data Documentation

◆ $cacheIdentifier

TYPO3\CMS\Core\Core\ClassLoader::$cacheIdentifier
protected

Definition at line 58 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\setCacheIdentifier().

◆ $classAliasMap

TYPO3\CMS\Core\Core\ClassLoader::$classAliasMap
protected

Definition at line 38 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\injectClassAliasMap().

◆ $classesCache

TYPO3\CMS\Core\Core\ClassLoader::$classesCache
protected

Definition at line 48 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\injectClassesCache().

◆ $context

TYPO3\CMS\Core\Core\ClassLoader::$context
protected

Definition at line 33 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\__construct().

◆ $coreCache

TYPO3\CMS\Core\Core\ClassLoader::$coreCache
protected

Definition at line 53 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\injectCoreCache().

◆ $isEarlyCache

TYPO3\CMS\Core\Core\ClassLoader::$isEarlyCache = TRUE
protected

Definition at line 68 of file ClassLoader.php.

◆ $isLoadingLocker

TYPO3\CMS\Core\Core\ClassLoader::$isLoadingLocker = FALSE
protected

Definition at line 94 of file ClassLoader.php.

◆ $lockObject

TYPO3\CMS\Core\Core\ClassLoader::$lockObject = NULL
protected

◆ $packageClassesPaths

TYPO3\CMS\Core\Core\ClassLoader::$packageClassesPaths = array()
protected

◆ $packageNamespaces

TYPO3\CMS\Core\Core\ClassLoader::$packageNamespaces = array()
protected

◆ $packages

TYPO3\CMS\Core\Core\ClassLoader::$packages = array()
protected

Definition at line 63 of file ClassLoader.php.

Referenced by TYPO3\CMS\Core\Core\ClassLoader\setPackages().

◆ $runtimeClassLoadingInformationCache

TYPO3\CMS\Core\Core\ClassLoader::$runtimeClassLoadingInformationCache = array()
protected

Definition at line 73 of file ClassLoader.php.

◆ $shutdownRegistered

TYPO3\CMS\Core\Core\ClassLoader::$shutdownRegistered = FALSE
protected

Definition at line 106 of file ClassLoader.php.

◆ $staticAliasMap

TYPO3\CMS\Core\Core\ClassLoader::$staticAliasMap
staticprotected

Definition at line 43 of file ClassLoader.php.

◆ VALID_CLASSNAME_PATTERN

const TYPO3\CMS\Core\Core\ClassLoader::VALID_CLASSNAME_PATTERN = '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9\\\\_\x7f-\xff]*$/'

Definition at line 28 of file ClassLoader.php.