FailsafePackageManager extends PackageManager
This is an intermediate package manager that loads just the required extensions for the install in case the package states are unavailable.
Table of Contents
Properties
- $activePackages : mixed
- List of active packages as package key => package object
- $availablePackagesScanned : bool
- $composerNameToPackageKeyMap : mixed
- A map between ComposerName and PackageKey, only available when scanAvailablePackages is run, e.g. `['typo3/cms-core' => 'core', 'typo3/cms-backend' => 'backend']`
- $dependencyOrderingService : DependencyOrderingService
- $inFailsafeMode : bool
- $packageAliasMap : mixed
- $packageCache : PackageCacheInterface
- $packagePathMatchRegex : string|null
- The regex to match paths with EXT:{package/key}
- $packages : mixed
- Array of available packages, indexed by package key
- $packagesBasePath : string
- Absolute path leading to the various package directories
- $packagesBasePaths : array{local?: non-empty-string, system?: non-empty-string}
- $packageStatesConfiguration : mixed
- Package states configuration as stored in the PackageStates.php file
- $packageStatesPathAndFilename : string
Methods
- __construct() : mixed
- activatePackage() : mixed
- deactivatePackage() : mixed
- Deactivates a package and updates the packagestates configuration
- deletePackage() : mixed
- Removes a package from the file system.
- extractPackageKeyFromPackagePath() : string
- Extracts the package key from a path in the form EXT:vendor/package/Path/To/Resource
- forceSortAndSavePackageStates() : mixed
- To enable writing of the package states file the package states migration needs to override eventual failsafe blocks.
- getActivePackages() : mixed
- Returns an array of \TYPO3\CMS\Core\Package objects of all active packages.
- getAvailablePackages() : mixed
- Returns an array of \TYPO3\CMS\Core\Package objects of all available packages.
- getCacheIdentifier() : string|null
- getComposerManifest() : stdClass
- Returns contents of Composer manifest as a stdObject
- getPackage() : PackageInterface
- Returns a PackageInterface object for the specified package.
- getPackageKeyFromComposerName() : string|PackageKey|PackageName
- Resolves a TYPO3 package key from a composer package name.
- initialize() : mixed
- Initializes the package manager
- isPackageActive() : bool
- Returns TRUE if a package is activated or FALSE if it's not.
- isPackageAvailable() : bool
- Returns TRUE if a package is available (the package's files exist in the packages directory) or FALSE if it's not. If a package is available it doesn't mean necessarily that it's active!
- isPackageKeyValid() : bool
- Check the conformance of the given package key
- packagesMayHaveChanged() : void
- Event listener to retrigger scanning of available packages.
- recreatePackageStatesFileIfMissing() : void
- Create PackageStates.php if missing and LocalConfiguration exists, used to have an Install Tool session running
- registerPackage() : PackageInterface
- Register a native TYPO3 package
- reloadPackageInformation() : mixed
- Reloads a package and its information
- resolvePackagePath() : string
- Resolves a path in the form EXT:vendor/package/Path/To/Resource to an absolute filesystem path
- scanAvailablePackages() : mixed
- Scans all directories in the packages directories for available packages.
- setPackageCache() : mixed
- unregisterPackage() : mixed
- Unregisters a package from the list of available packages
- warmupCaches() : void
- addDependencyToFrameworkToAllExtensions() : mixed
- Adds all root packages of current dependency graph as dependency to all extensions
- buildDependencyGraph() : mixed
- Builds the dependency graph for all packages
- convertConfigurationForGraph() : array<string|int, mixed>
- Convert the package configuration into a dependency definition
- findFrameworkPackages() : array<int, PackageKey>
- getDependencyArrayForPackage() : array<int, string>|null
- Returns an array of dependent package keys for the given package. It will do this recursively, so dependencies of dependent packages will also be in the result.
- getExtensionEmConf() : array<string|int, mixed>|null
- Fetches MetaData information from ext_emconf.php, used for resolving dependencies as well.
- getPackageBasePaths() : array{local?: string, system?: string}
- The order of paths is crucial for allowing overriding of system extension by local extensions.
- getPackageKeyFromManifest() : string
- Resolves package key from Composer manifest
- getSuggestionArrayForPackage() : array<int, PackageKey>|null
- Returns an array of suggested package keys for the given package.
- hasSubDirectories() : bool
- Returns true if the given path has valid subdirectories, false otherwise.
- initializePackageObjects() : mixed
- Initializes activePackages property
- isComposerDependency() : bool
- Checks whether the given package name is a Composer dependency.
- isPackageRegistered() : bool
- Returns TRUE if a package was already registered or FALSE if it's not.
- loadPackageManagerStatesFromCache() : mixed
- Attempts to load the package manager states from cache
- loadPackageStates() : mixed
- Loads the states of available packages from the PackageStates.php file.
- mapExtensionManagerConfigurationToComposerManifest() : stdClass
- Fetches information from ext_emconf.php and maps it so it is treated as it would come from composer.json
- registerActivePackage() : mixed
- registerPackagesFromConfiguration() : mixed
- Requires and registers all packages which were defined in packageStatesConfiguration
- registerTransientClassLoadingInformationForPackage() : mixed
- resolvePackageDependencies() : mixed
- Resolves the dependent packages from the meta data of all packages recursively. The resolved direct or indirect dependencies of each package will put into the package states configuration array.
- savePackageStates() : mixed
- Save states
- saveToPackageCache() : void
- Never try to access the cache in failsafe mode
- scanPackagePathsForExtensions() : array<string|int, mixed>
- Fetches all directories from sysext/global/local locations and checks if the extension contains an ext_emconf.php
- setComposerManifestValueIfEmpty() : stdClass
- sortActivePackagesByDependencies() : mixed
- Orders all active packages by comparing their dependencies. By this, the packages and package configurations arrays holds all packages in the correct initialization order.
- sortAndSavePackageStates() : mixed
- Saves the current content of $this->packageStatesConfiguration to the PackageStates.php file.
- sortPackageStatesConfigurationByDependency() : array<int, PackageKey>
- unregisterPackageByPackageKey() : mixed
- Unregisters a package from the list of available packages
Properties
$activePackages
List of active packages as package key => package object
protected
mixed
$activePackages
= []
$availablePackagesScanned
protected
bool
$availablePackagesScanned
= false
$composerNameToPackageKeyMap
A map between ComposerName and PackageKey, only available when scanAvailablePackages is run, e.g. `['typo3/cms-core' => 'core', 'typo3/cms-backend' => 'backend']`
protected
mixed
$composerNameToPackageKeyMap
= []
$dependencyOrderingService
protected
DependencyOrderingService
$dependencyOrderingService
$inFailsafeMode
protected
bool
$inFailsafeMode
= false
TRUE if package manager is in failsafe mode
$packageAliasMap
protected
mixed
$packageAliasMap
= []
$packageCache
protected
PackageCacheInterface
$packageCache
$packagePathMatchRegex
The regex to match paths with EXT:{package/key}
protected
string|null
$packagePathMatchRegex
$packages
Array of available packages, indexed by package key
protected
mixed
$packages
= []
$packagesBasePath
Absolute path leading to the various package directories
protected
string
$packagesBasePath
$packagesBasePaths
protected
array{local?: non-empty-string, system?: non-empty-string}
$packagesBasePaths
= []
$packageStatesConfiguration
Package states configuration as stored in the PackageStates.php file
protected
mixed
$packageStatesConfiguration
= []
$packageStatesPathAndFilename
protected
string
$packageStatesPathAndFilename
Methods
__construct()
public
__construct(DependencyOrderingService $dependencyOrderingService[, string|null $packageStatesPathAndFilename = null ][, string|null $packagesBasePath = null ]) : mixed
Parameters
- $dependencyOrderingService : DependencyOrderingService
- $packageStatesPathAndFilename : string|null = null
- $packagesBasePath : string|null = null
activatePackage()
public
activatePackage(string|PackageKey $packageKey) : mixed
Parameters
- $packageKey : string|PackageKey
deactivatePackage()
Deactivates a package and updates the packagestates configuration
public
deactivatePackage(string|PackageKey $packageKey) : mixed
Parameters
- $packageKey : string|PackageKey
Tags
deletePackage()
Removes a package from the file system.
public
deletePackage(string|PackageKey $packageKey) : mixed
Parameters
- $packageKey : string|PackageKey
Tags
extractPackageKeyFromPackagePath()
Extracts the package key from a path in the form EXT:vendor/package/Path/To/Resource
public
extractPackageKeyFromPackagePath(string $path) : string
Parameters
- $path : string
Tags
Return values
stringforceSortAndSavePackageStates()
To enable writing of the package states file the package states migration needs to override eventual failsafe blocks.
public
forceSortAndSavePackageStates() : mixed
getActivePackages()
Returns an array of \TYPO3\CMS\Core\Package objects of all active packages.
public
getActivePackages() : mixed
A package is active, if it is available and has been activated in the package manager settings.
getAvailablePackages()
Returns an array of \TYPO3\CMS\Core\Package objects of all available packages.
public
getAvailablePackages() : mixed
A package is available, if the package directory contains valid meta information.
getCacheIdentifier()
public
getCacheIdentifier() : string|null
Return values
string|nullgetComposerManifest()
Returns contents of Composer manifest as a stdObject
public
getComposerManifest(string $manifestPath[, bool $ignoreExtEmConf = false ]) : stdClass
Parameters
- $manifestPath : string
- $ignoreExtEmConf : bool = false
Tags
Return values
stdClassgetPackage()
Returns a PackageInterface object for the specified package.
public
getPackage(string|PackageKey $packageKey) : PackageInterface
A package is available, if the package directory contains valid MetaData information.
Parameters
- $packageKey : string|PackageKey
Tags
Return values
PackageInterface —The requested package object
getPackageKeyFromComposerName()
Resolves a TYPO3 package key from a composer package name.
public
getPackageKeyFromComposerName(string|PackageName $composerName) : string|PackageKey|PackageName
Parameters
- $composerName : string|PackageName
Return values
string|PackageKey|PackageNameinitialize()
Initializes the package manager
public
initialize() : mixed
isPackageActive()
Returns TRUE if a package is activated or FALSE if it's not.
public
isPackageActive(string|PackageKey $packageKey) : bool
Parameters
- $packageKey : string|PackageKey
-
The key of the package to check
Return values
bool —TRUE if package is active, otherwise FALSE
isPackageAvailable()
Returns TRUE if a package is available (the package's files exist in the packages directory) or FALSE if it's not. If a package is available it doesn't mean necessarily that it's active!
public
isPackageAvailable(string|PackageKey $packageKey) : bool
Parameters
- $packageKey : string|PackageKey
-
The key of the package to check
Return values
bool —TRUE if the package is available, otherwise FALSE
isPackageKeyValid()
Check the conformance of the given package key
public
isPackageKeyValid(string|PackageKey $packageKey) : bool
Parameters
- $packageKey : string|PackageKey
-
The package key to validate
Return values
bool —If the package key is valid, returns TRUE otherwise FALSE
packagesMayHaveChanged()
Event listener to retrigger scanning of available packages.
public
packagesMayHaveChanged(PackagesMayHaveChangedEvent $event) : void
Parameters
- $event : PackagesMayHaveChangedEvent
recreatePackageStatesFileIfMissing()
Create PackageStates.php if missing and LocalConfiguration exists, used to have an Install Tool session running
public
recreatePackageStatesFileIfMissing([bool $useFactoryDefault = false ]) : void
It is fired if PackageStates.php is deleted on a running instance, all packages marked as "part of minimal system" are activated in this case.
Parameters
- $useFactoryDefault : bool = false
-
if true, use the "isPartOfFactoryDefault" otherwise use "isPartOfMinimalUsableSystem"
registerPackage()
Register a native TYPO3 package
public
registerPackage(PackageInterface $package) : PackageInterface
Parameters
- $package : PackageInterface
-
The Package to be registered
Tags
Return values
PackageInterfacereloadPackageInformation()
Reloads a package and its information
public
reloadPackageInformation(string|PackageKey $packageKey) : mixed
Parameters
- $packageKey : string|PackageKey
Tags
resolvePackagePath()
Resolves a path in the form EXT:vendor/package/Path/To/Resource to an absolute filesystem path
public
resolvePackagePath(string $path) : string
Parameters
- $path : string
Tags
Return values
stringscanAvailablePackages()
Scans all directories in the packages directories for available packages.
public
scanAvailablePackages() : mixed
For each package a Package object is created and stored in $this->packages.
setPackageCache()
public
setPackageCache(PackageCacheInterface $packageCache) : mixed
Parameters
- $packageCache : PackageCacheInterface
unregisterPackage()
Unregisters a package from the list of available packages
public
unregisterPackage(PackageInterface $package) : mixed
Parameters
- $package : PackageInterface
-
The package to be unregistered
Tags
warmupCaches()
public
warmupCaches(CacheWarmupEvent $event) : void
Parameters
- $event : CacheWarmupEvent
addDependencyToFrameworkToAllExtensions()
Adds all root packages of current dependency graph as dependency to all extensions
protected
addDependencyToFrameworkToAllExtensions(array<string|int, mixed> $packageStateConfiguration, array<int, PackageKey> $rootPackageKeys) : mixed
This ensures that the framework extensions (aka sysext) are always loaded first, before any other external extension.
Parameters
- $packageStateConfiguration : array<string|int, mixed>
- $rootPackageKeys : array<int, PackageKey>
buildDependencyGraph()
Builds the dependency graph for all packages
protected
buildDependencyGraph(array<string|int, mixed> $packageStateConfiguration) : mixed
This method also introduces dependencies among the dependencies to ensure the loading order is exactly as specified in the list.
Parameters
- $packageStateConfiguration : array<string|int, mixed>
convertConfigurationForGraph()
Convert the package configuration into a dependency definition
protected
convertConfigurationForGraph(array<string|int, mixed> $packageStatesConfiguration, array<string|int, mixed> $packageKeys) : array<string|int, mixed>
This converts "dependencies" and "suggestions" to "after" syntax for the usage in DependencyOrderingService
Parameters
- $packageStatesConfiguration : array<string|int, mixed>
- $packageKeys : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>findFrameworkPackages()
protected
findFrameworkPackages(array<string|int, mixed> $packageStateConfiguration) : array<int, PackageKey>
Parameters
- $packageStateConfiguration : array<string|int, mixed>
Return values
array<int, PackageKey>getDependencyArrayForPackage()
Returns an array of dependent package keys for the given package. It will do this recursively, so dependencies of dependent packages will also be in the result.
protected
getDependencyArrayForPackage(string|PackageKey $packageKey[, array<string|int, mixed> &$dependentPackageKeys = [] ][, array<string|int, mixed> $trace = [] ]) : array<int, string>|null
Parameters
- $packageKey : string|PackageKey
-
The package key to fetch the dependencies for
- $dependentPackageKeys : array<string|int, mixed> = []
- $trace : array<string|int, mixed> = []
-
An array of already visited package keys, to detect circular dependencies
Tags
Return values
array<int, string>|null —An array of direct or indirect dependent packages
getExtensionEmConf()
Fetches MetaData information from ext_emconf.php, used for resolving dependencies as well.
protected
getExtensionEmConf(string $packagePath, string $packageKey) : array<string|int, mixed>|null
Parameters
- $packagePath : string
- $packageKey : string
Tags
Return values
array<string|int, mixed>|null —if no ext_emconf.php was found, or the contents of the ext_emconf.php file.
getPackageBasePaths()
The order of paths is crucial for allowing overriding of system extension by local extensions.
protected
getPackageBasePaths() : array{local?: string, system?: string}
Pay attention if you change order of the paths here.
Return values
array{local?: string, system?: string}getPackageKeyFromManifest()
Resolves package key from Composer manifest
protected
getPackageKeyFromManifest(object $manifest, string $packagePath) : string
If it is a TYPO3 package the name of the containing directory will be used.
Else if the composer name of the package matches the first part of the lowercased namespace of the package, the mixed case version of the composer name / namespace will be used, with backslashes replaced by dots.
Else the composer name will be used with the slash replaced by a dot
Parameters
- $manifest : object
- $packagePath : string
Tags
Return values
stringgetSuggestionArrayForPackage()
Returns an array of suggested package keys for the given package.
protected
getSuggestionArrayForPackage(string|PackageKey $packageKey) : array<int, PackageKey>|null
Parameters
- $packageKey : string|PackageKey
-
The package key to fetch the suggestions for
Return values
array<int, PackageKey>|null —An array of directly suggested packages
hasSubDirectories()
Returns true if the given path has valid subdirectories, false otherwise.
protected
hasSubDirectories(string $path) : bool
Parameters
- $path : string
Return values
boolinitializePackageObjects()
Initializes activePackages property
protected
initializePackageObjects() : mixed
Saves PackageStates.php if list of required extensions has changed.
isComposerDependency()
Checks whether the given package name is a Composer dependency.
protected
isComposerDependency(string $packageName) : bool
In non Composer mode this is always false
Parameters
- $packageName : string
Return values
boolisPackageRegistered()
Returns TRUE if a package was already registered or FALSE if it's not.
protected
isPackageRegistered(string|PackageKey $packageKey) : bool
Parameters
- $packageKey : string|PackageKey
Return values
boolloadPackageManagerStatesFromCache()
Attempts to load the package manager states from cache
protected
loadPackageManagerStatesFromCache() : mixed
Tags
loadPackageStates()
Loads the states of available packages from the PackageStates.php file.
protected
loadPackageStates() : mixed
The result is stored in $this->packageStatesConfiguration.
mapExtensionManagerConfigurationToComposerManifest()
Fetches information from ext_emconf.php and maps it so it is treated as it would come from composer.json
protected
mapExtensionManagerConfigurationToComposerManifest(string|PackageKey $packageKey, array<string|int, mixed> $extensionManagerConfiguration, stdClass $composerManifest) : stdClass
Parameters
- $packageKey : string|PackageKey
- $extensionManagerConfiguration : array<string|int, mixed>
- $composerManifest : stdClass
Tags
Return values
stdClassregisterActivePackage()
protected
registerActivePackage(PackageInterface $package) : mixed
Parameters
- $package : PackageInterface
registerPackagesFromConfiguration()
Requires and registers all packages which were defined in packageStatesConfiguration
protected
registerPackagesFromConfiguration(array<string|int, mixed> $packages[, bool $registerOnlyNewPackages = false ]) : mixed
Parameters
- $packages : array<string|int, mixed>
- $registerOnlyNewPackages : bool = false
Tags
registerTransientClassLoadingInformationForPackage()
protected
registerTransientClassLoadingInformationForPackage(PackageInterface $package) : mixed
Parameters
- $package : PackageInterface
Tags
resolvePackageDependencies()
Resolves the dependent packages from the meta data of all packages recursively. The resolved direct or indirect dependencies of each package will put into the package states configuration array.
protected
resolvePackageDependencies(mixed $packageConfig) : mixed
Parameters
- $packageConfig : mixed
savePackageStates()
Save states
protected
savePackageStates() : mixed
saveToPackageCache()
Never try to access the cache in failsafe mode
protected
saveToPackageCache() : void
scanPackagePathsForExtensions()
Fetches all directories from sysext/global/local locations and checks if the extension contains an ext_emconf.php
protected
scanPackagePathsForExtensions() : array<string|int, mixed>
Return values
array<string|int, mixed>setComposerManifestValueIfEmpty()
protected
setComposerManifestValueIfEmpty(stdClass $manifest, string $property, mixed $value) : stdClass
Parameters
- $manifest : stdClass
- $property : string
- $value : mixed
Return values
stdClasssortActivePackagesByDependencies()
Orders all active packages by comparing their dependencies. By this, the packages and package configurations arrays holds all packages in the correct initialization order.
protected
sortActivePackagesByDependencies() : mixed
sortAndSavePackageStates()
Saves the current content of $this->packageStatesConfiguration to the PackageStates.php file.
protected
sortAndSavePackageStates() : mixed
Tags
sortPackageStatesConfigurationByDependency()
protected
sortPackageStatesConfigurationByDependency(array<string|int, mixed> $packageStatesConfiguration) : array<int, PackageKey>
Parameters
- $packageStatesConfiguration : array<string|int, mixed>
Tags
Return values
array<int, PackageKey> —Returns the packageStatesConfiguration sorted by dependencies
unregisterPackageByPackageKey()
Unregisters a package from the list of available packages
protected
unregisterPackageByPackageKey(string|PackageKey $packageKey) : mixed
Parameters
- $packageKey : string|PackageKey
-
Package Key of the package to be unregistered