UnitTestPackageManager extends PackageManager
This is an intermediate package manager that loads all extensions that are present in one of the package base paths, so that the class loader can find the classes of all tests, whether the according extension is active in the installation itself or not.
Table of Contents
Properties
- $activePackages : array<string|int, mixed>
- List of active packages as package key => package object
- $availablePackagesScanned : bool
- $composerNameToPackageKeyMap : array<string|int, mixed>
- A map between ComposerName and PackageKey, only available when scanAvailablePackages is run
- $dependencyOrderingService : DependencyOrderingService
- $packageAliasMap : array<string|int, mixed>
- $packageCache : PackageCacheInterface
- $packagePathMatchRegex : string|null
- The regex to match paths with EXT:{package/key}
- $packages : array<string|int, PackageInterface>
- Array of available packages, indexed by package key
- $packagesBasePath : string
- Absolute path leading to the various package directories
- $packagesBasePaths : array<string|int, mixed>
- $packageStatesConfiguration : array<string|int, 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
- getActivePackages() : array<string|int, PackageInterface>
- Returns an array of \TYPO3\CMS\Core\Package objects of all active packages.
- getAvailablePackages() : array<string|int, PackageInterface>
- 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
- 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.
- 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() : array<string|int, mixed>
- Adds all root packages of current dependency graph as dependency to all extensions
- buildDependencyGraph() : array<string|int, mixed>
- Builds the dependency graph for all packages
- convertConfigurationForGraph() : array<string|int, mixed>
- Convert the package configuration into a dependency definition
- findFrameworkPackages() : array<string|int, mixed>
- getDependencyArrayForPackage() : array<string|int, mixed>|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<string|int, mixed>
- 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<string|int, mixed>|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() : array<string|int, 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
- Saves the current content of $this->packageStatesConfiguration to the PackageStates.php file.
- saveToPackageCache() : void
- Saves the current state of all relevant information in the package cache
- 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() : array<string|int, 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
- Overwrite the original method to avoid resolving dependencies (which we do not need) and saving the PackageStates.php file (which we do not want), when calling scanAvailablePackages()
- sortPackageStatesConfigurationByDependency() : array<string|int, mixed>
- unregisterPackageByPackageKey() : mixed
- Unregisters a package from the list of available packages
Properties
$activePackages
List of active packages as package key => package object
protected
array<string|int, mixed>
$activePackages
= []
$availablePackagesScanned
protected
bool
$availablePackagesScanned
= false
$composerNameToPackageKeyMap
A map between ComposerName and PackageKey, only available when scanAvailablePackages is run
protected
array<string|int, mixed>
$composerNameToPackageKeyMap
= []
$dependencyOrderingService
protected
DependencyOrderingService
$dependencyOrderingService
$packageAliasMap
protected
array<string|int, 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
array<string|int, PackageInterface>
$packages
= []
$packagesBasePath
Absolute path leading to the various package directories
protected
string
$packagesBasePath
$packagesBasePaths
protected
array<string|int, mixed>
$packagesBasePaths
= []
$packageStatesConfiguration
Package states configuration as stored in the PackageStates.php file
protected
array<string|int, 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) : mixed
Parameters
- $packageKey : string
deactivatePackage()
Deactivates a package and updates the packagestates configuration
public
deactivatePackage(string $packageKey) : mixed
Parameters
- $packageKey : string
Tags
deletePackage()
Removes a package from the file system.
public
deletePackage(string $packageKey) : mixed
Parameters
- $packageKey : string
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
stringgetActivePackages()
Returns an array of \TYPO3\CMS\Core\Package objects of all active packages.
public
getActivePackages() : array<string|int, PackageInterface>
A package is active, if it is available and has been activated in the package manager settings.
Return values
array<string|int, PackageInterface>getAvailablePackages()
Returns an array of \TYPO3\CMS\Core\Package objects of all available packages.
public
getAvailablePackages() : array<string|int, PackageInterface>
A package is available, if the package directory contains valid meta information.
Return values
array<string|int, PackageInterface> —Array of PackageInterface
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) : PackageInterface
A package is available, if the package directory contains valid MetaData information.
Parameters
- $packageKey : string
Tags
Return values
PackageInterface —The requested package object
getPackageKeyFromComposerName()
Resolves a TYPO3 package key from a composer package name.
public
getPackageKeyFromComposerName(string $composerName) : string
Parameters
- $composerName : string
Return values
stringinitialize()
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) : bool
Parameters
- $packageKey : string
-
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) : bool
Parameters
- $packageKey : string
-
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) : bool
Parameters
- $packageKey : string
-
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
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) : mixed
Parameters
- $packageKey : string
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<string|int, mixed> $rootPackageKeys) : array<string|int, 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<string|int, mixed>
Return values
array<string|int, mixed>buildDependencyGraph()
Builds the dependency graph for all packages
protected
buildDependencyGraph(array<string|int, mixed> $packageStateConfiguration) : array<string|int, 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>
Return values
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<string|int, mixed>
Parameters
- $packageStateConfiguration : array<string|int, mixed>
Return values
array<string|int, mixed>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[, array<string|int, mixed> &$dependentPackageKeys = [] ][, array<string|int, mixed> $trace = [] ]) : array<string|int, mixed>|null
Parameters
- $packageKey : string
-
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<string|int, mixed>|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<string|int, mixed>
Pay attention if you change order of the paths here.
Return values
array<string|int, mixed>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) : array<string|int, mixed>|null
Parameters
- $packageKey : string
-
The package key to fetch the suggestions for
Return values
array<string|int, mixed>|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) : bool
Parameters
- $packageKey : string
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.
Tags
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, array<string|int, mixed> $extensionManagerConfiguration, stdClass $composerManifest) : stdClass
Parameters
- $packageKey : string
- $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(array<string|int, mixed> $packageConfig) : array<string|int, mixed>
Parameters
- $packageConfig : array<string|int, mixed>
Return values
array<string|int, mixed>savePackageStates()
Saves the current content of $this->packageStatesConfiguration to the PackageStates.php file.
protected
savePackageStates() : mixed
Tags
saveToPackageCache()
Saves the current state of all relevant information in the package cache
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() : array<string|int, mixed>
Return values
array<string|int, mixed>sortAndSavePackageStates()
Overwrite the original method to avoid resolving dependencies (which we do not need) and saving the PackageStates.php file (which we do not want), when calling scanAvailablePackages()
protected
sortAndSavePackageStates() : mixed
sortPackageStatesConfigurationByDependency()
protected
sortPackageStatesConfigurationByDependency(array<string|int, mixed> $packageStatesConfiguration) : array<string|int, mixed>
Parameters
- $packageStatesConfiguration : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —Returns the packageStatesConfiguration sorted by dependencies
unregisterPackageByPackageKey()
Unregisters a package from the list of available packages
protected
unregisterPackageByPackageKey(string $packageKey) : mixed
Parameters
- $packageKey : string
-
Package Key of the package to be unregistered