137 $this->classAliasMap->injectCoreCache($coreCache);
149 $this->isEarlyCache = FALSE;
150 $this->classAliasMap->injectClassesCache($classesCache);
151 foreach ($earlyClassesCache->getByTag(
'early') as $originalClassLoadingInformation) {
152 $classLoadingInformation = explode(
"\xff", $originalClassLoadingInformation);
153 $cacheEntryIdentifier = strtolower(str_replace(
'\\',
'_', $classLoadingInformation[1]));
154 if (!$this->classesCache->has($cacheEntryIdentifier)) {
155 $this->classesCache->set($cacheEntryIdentifier, $originalClassLoadingInformation);
170 if ($className[0] ===
'\\') {
171 $className = substr($className, 1);
178 $cacheEntryIdentifier = strtolower(str_replace(
'\\',
'_', $className));
181 if ($classLoadingInformation === FALSE) {
191 $loadingSuccessful = FALSE;
192 if (!empty($classLoadingInformation)) {
195 $loadingSuccessful = class_exists($classLoadingInformation[1], FALSE)
196 || interface_exists($classLoadingInformation[1], FALSE)
197 || (bool)require_once $classLoadingInformation[0];
199 if ($loadingSuccessful && count($classLoadingInformation) > 2) {
200 $originalClassName = $classLoadingInformation[1];
201 foreach (array_slice($classLoadingInformation, 2) as $aliasClassName) {
206 return $loadingSuccessful;
220 $rawClassLoadingInformation = $this->classesCache->get($cacheEntryIdentifier);
222 if ($rawClassLoadingInformation ===
'') {
226 if ($rawClassLoadingInformation) {
227 return explode(
"\xff", $rawClassLoadingInformation);
246 if (!$this->isEarlyCache) {
253 if ($classLoadingInformation === FALSE) {
257 if ($classLoadingInformation !== FALSE) {
259 $this->classesCache->set(
260 $cacheEntryIdentifier,
261 implode(
"\xff", $classLoadingInformation),
262 $this->isEarlyCache ? array(
'early') : array()
264 } elseif (!$this->isEarlyCache) {
265 if ($this->context->isProduction()) {
267 $this->classesCache->set($cacheEntryIdentifier,
'');
274 return $classLoadingInformation;
287 if ($classLoadingInformation === FALSE) {
291 if ($classLoadingInformation === FALSE) {
295 if ($classLoadingInformation === FALSE) {
299 if ($classLoadingInformation === FALSE) {
318 return $classLoadingInformation;
328 return (
bool)preg_match(self::VALID_CLASSNAME_PATTERN, $className);
338 if (substr($className, 0, 14) ===
'TYPO3\\CMS\\Core') {
339 $classesFolder = substr($className, 15, 5) ===
'Tests' ?
'' :
'Classes/';
340 $classFilePath = PATH_typo3 .
'sysext/core/' . $classesFolder . str_replace(
'\\',
'/', substr($className, 15)) .
'.php';
341 if (@file_exists($classFilePath)) {
342 return array($classFilePath, $className);
355 $lowercasedClassName = strtolower($className);
356 if (!isset($this->runtimeClassLoadingInformationCache[$lowercasedClassName])) {
359 $classInformation = $this->runtimeClassLoadingInformationCache[$lowercasedClassName];
360 return @file_exists($classInformation[0]) ? $classInformation : FALSE;
370 foreach ($this->packageNamespaces as $packageNamespace => $packageData) {
371 if (substr(str_replace(
'_',
'\\', $className), 0, $packageData[
'namespaceLength']) === $packageNamespace) {
372 if ($packageData[
'substituteNamespaceInPath']) {
375 $classPathAndFilename =
'/' . str_replace(
'\\',
'/', ltrim(substr($className, $packageData[
'namespaceLength']),
'\\')) .
'.php';
378 $classPathAndFilename =
'';
379 $lastNamespacePosition = strrpos($className,
'\\');
380 if ($lastNamespacePosition !== FALSE) {
381 $namespace = substr($className, 0, $lastNamespacePosition);
382 $className = substr($className, $lastNamespacePosition + 1);
383 $classPathAndFilename = str_replace(
'\\',
'/', $namespace) .
'/';
385 $classPathAndFilename .= str_replace(
'_',
'/', $className) .
'.php';
387 if (strtolower(substr($className, $packageData[
'namespaceLength'], 5)) ===
'tests') {
388 $classPathAndFilename = $packageData[
'packagePath'] . $classPathAndFilename;
390 $classPathAndFilename = $packageData[
'classesPath'] . $classPathAndFilename;
392 if (@file_exists($classPathAndFilename)) {
393 return array($classPathAndFilename, $className);
410 if (strpos($className,
'\\') !== FALSE) {
414 $classNameParts = explode($delimiter, $className, 4);
418 if (count($classNameParts) <= 2) {
423 isset($classNameParts[0])
424 && isset($classNameParts[1])
425 && $classNameParts[0] ===
'TYPO3' 426 && $classNameParts[1] ===
'CMS' 429 $classNameWithoutVendorAndProduct = $classNameParts[3];
432 $classNameWithoutVendorAndProduct = $classNameParts[2];
434 if (isset($classNameParts[3])) {
435 $classNameWithoutVendorAndProduct .= $delimiter . $classNameParts[3];
439 if ($extensionKey && isset($this->packageClassesPaths[$extensionKey])) {
440 if (substr(strtolower($classNameWithoutVendorAndProduct), 0, 5) ===
'tests') {
441 $classesPath = $this->packages[$extensionKey]->getPackagePath();
443 $classesPath = $this->packageClassesPaths[$extensionKey];
445 $classFilePath = $classesPath . strtr($classNameWithoutVendorAndProduct, $delimiter,
'/') .
'.php';
446 if (@file_exists($classFilePath)) {
447 return array($classFilePath, $className);
460 return $this->cacheIdentifier !== NULL
461 ?
'ClassLoader_' . $this->cacheIdentifier
488 $this->classAliasMap->setPackages($packages);
491 $this->runtimeClassLoadingInformationCache = array();
502 $packageKey = $package->getPackageKey();
503 if (!isset($this->packages[$packageKey])) {
504 $this->packages[$packageKey] = $package;
524 foreach ($this->packages as $package) {
531 $classNameToAliasMapping = $this->classAliasMap->setPackages($this->packages)->buildMappingAndInitializeEarlyInstanceMapping();
533 $this->classAliasMap->buildMappingFiles($classNameToAliasMapping);
557 if ($package instanceof PackageInterface) {
569 if ($cacheEntryIdentifier === NULL) {
572 $packageData = $this->coreCache->requireOnce($cacheEntryIdentifier);
573 if ($packageData !== FALSE) {
591 $packageNamespace = $package->getNamespace();
593 if ($packageNamespace[0] !==
'*') {
594 $this->packageNamespaces[$packageNamespace] = array(
595 'namespaceLength' => strlen($packageNamespace),
596 'classesPath' => $package->getClassesPath(),
597 'packagePath' => $package->getPackagePath(),
610 $classFileAutoloadRegistry = array();
611 foreach ($packages as $package) {
613 $classFilesFromAutoloadRegistry = $package->getClassFilesFromAutoloadRegistry();
614 if (is_array($classFilesFromAutoloadRegistry)) {
615 $classFileAutoloadRegistry = array_merge($classFileAutoloadRegistry, $classFilesFromAutoloadRegistry);
619 foreach ($classFileAutoloadRegistry as $className => $classFilePath) {
620 $lowercasedClassName = strtolower($className);
621 if (!isset($this->runtimeClassLoadingInformationCache[$lowercasedClassName]) && @file_exists($classFilePath)) {
622 $this->runtimeClassLoadingInformationCache[$lowercasedClassName] = array($classFilePath, $className);
634 foreach ($this->runtimeClassLoadingInformationCache as $classLoadingInformation) {
635 $cacheEntryIdentifier = strtolower(str_replace(
'\\',
'_', $classLoadingInformation[1]));
636 if (!$this->classesCache->has($cacheEntryIdentifier)) {
637 $this->classesCache->set($cacheEntryIdentifier, implode(
"\xff", $classLoadingInformation));
649 $this->packageClassesPaths[$packageToReplace] = $package->
getClassesPath();
660 if ($cacheEntryIdentifier !== NULL) {
661 $this->coreCache->set(
663 'return ' . var_export(array($this->packageNamespaces, $this->packageClassesPaths), TRUE) .
';' 674 $sortPackages =
function ($a, $b) {
675 if (($lenA = strlen($a)) === ($lenB = strlen($b))) {
676 return strcmp($a, $b);
678 return $lenA > $lenB ? -1 : 1;
680 uksort($this->packageNamespaces, $sortPackages);
690 foreach ($classFileAutoloadRegistry as $className => $classFilePath) {
691 $lowercasedClassName = strtolower($className);
692 if (!isset($this->runtimeClassLoadingInformationCache[$lowercasedClassName])) {
693 $this->runtimeClassLoadingInformationCache[$lowercasedClassName] = array($classFilePath, $className);
706 return $this->classAliasMap->setAliasForClassName($aliasClassName, $originalClassName);
716 return static::$staticAliasMap->getClassNameForAlias($alias);
728 $aliases = static::$staticAliasMap->getAliasesForClassName($className);
729 return is_array($aliases) && isset($aliases[0]) ? $aliases[0] : NULL;
739 return static::$staticAliasMap->getAliasesForClassName($className);
749 if (!$this->isLoadingLocker) {
761 throw new \RuntimeException(
'Could not acquire lock for ClassLoader cache creation.', 1394480725);
764 if (!$this->shutdownRegistered) {
765 $this->shutdownRegistered = TRUE;
766 register_shutdown_function(array($this,
'checkForCrashAndCleanup'));
793 $error = error_get_last();
798 if ($error !== NULL && $this->lockObject !== NULL && $this->lockObject->getLockStatus()) {
823 $this->coreCache->flush();
824 $this->classesCache->flush();
834 if (NULL === $this->lockObject) {
835 $this->isLoadingLocker = TRUE;
839 }
catch (\RuntimeException $e) {
853 $this->lockObject->setEnableLogging(FALSE);
854 $this->isLoadingLocker = FALSE;
buildClassLoadingInformationForClassFromCorePackage($className)
injectCoreCache(Cache\Frontend\PhpFrontend $coreCache)
buildPackageNamespace(\TYPO3\Flow\Package\PackageInterface $package)
isValidClassName($className)
addActivePackage(\TYPO3\Flow\Package\PackageInterface $package)
getPackageReplacementKeys()
const TYPO3_enterInstallScript
static getClassNameForAlias($alias)
static logDeprecatedFunction()
static getAliasesForClassName($className)
static camelCaseToLowerCaseUnderscored($string)
const LOCKING_METHOD_SIMPLE
fetchClassLoadingInformationFromRuntimeCache($className)
setPackages(array $packages)
checkForCrashAndCleanup()
buildClassLoadingInformationForClassFromRegisteredPackages($className)
loadClassFilesFromAutoloadRegistryIntoRuntimeClassInformationCache(array $packages)
buildClassLoadingInformationForClassByNamingConvention($className)
getClassLoadingInformationFromCache($cacheEntryIdentifier)
injectClassAliasMap(ClassAliasMap $classAliasMap)
setRuntimeClassLoadingInformationFromAutoloadRegistry(array $classFileAutoloadRegistry)
loadPackageNamespacesFromCache()
const VALID_CLASSNAME_PATTERN
setAliasForClassName($aliasClassName, $originalClassName)
savePackageNamespacesAndClassesPathsToCache()
setCacheIdentifier($cacheIdentifier)
injectClassesCache(Cache\Frontend\StringFrontend $classesCache)
getCacheEntryIdentifier()
$runtimeClassLoadingInformationCache
buildClassLoadingInformation($className)
__construct(ApplicationContext $context)
releaseLock($needRelease)
buildPackageNamespaceAndClassesPath(\TYPO3\Flow\Package\PackageInterface $package)
buildCachedClassLoadingInformation($cacheEntryIdentifier, $className)
buildPackageClassPathsForLegacyExtension(PackageInterface $package)
static getAliasForClassName($className)
transferRuntimeClassInformationCacheEntriesToClassesCache()
buildPackageNamespacesAndClassesPaths()