PackageArtifactBuilder extends PackageManager implements InstallerScript

The builder is a subclass of PackageManager as it shares much of its functionality.

It evaluates the installed Composer packages for applicable TYPO3 extensions. All Composer packages will be discovered, that have an extra.typo3/cms definition in their composer.json. All ext_emconf.php files will be completely ignored in this context, which means all extensions are required to have a composer.json file, which works out naturally with a Composer setup.

Internal

This class is an implementation detail and does not represent public API

Tags
template

packageMap of array<int, array{PackageInterface, string, non-empty-string}>

template

IOMessage of array{severity: 'title'|'info'|'warning', verbosity: int, message: string}

Table of Contents

Interfaces

InstallerScript

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
$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
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.
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
run()  : bool
Entry method called in Composer post-dump-autoload hook
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
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()  : 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 = []

$packageAliasMap

protected mixed $packageAliasMap = []

$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

activatePackage()

public activatePackage(string|PackageKey $packageKey) : mixed
Parameters
$packageKey : string|PackageKey
Internal

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
Internal
Tags
throws
UnknownPackageException
throws
UnknownPackagePathException
Return values
string

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
Internal
Return values
string|null

getComposerManifest()

Returns contents of Composer manifest as a stdObject

public getComposerManifest(string $manifestPath[, bool $ignoreExtEmConf = false ]) : stdClass
Parameters
$manifestPath : string
$ignoreExtEmConf : bool = false
Internal
Tags
throws
InvalidPackageManifestException
Return values
stdClass

getPackage()

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
throws
UnknownPackageException

if the specified package is not known

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
Internal
Return values
string|PackageKey|PackageName

initialize()

Initializes the package manager

public initialize() : mixed
Internal

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

reloadPackageInformation()

Reloads a package and its information

public reloadPackageInformation(string|PackageKey $packageKey) : mixed
Parameters
$packageKey : string|PackageKey
Internal
Tags
throws
InvalidPackageStateException

if the package isn't available

scanAvailablePackages()

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.

Internal

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
throws
UnexpectedValueException
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
throws
InvalidPackageKeyException
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
throws
InvalidPackageManifestException
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
throws
InvalidPackageManifestException
Return values
string

getSuggestionArrayForPackage()

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
bool

initializePackageObjects()

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
bool

isPackageRegistered()

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
bool

loadPackageStates()

Loads the states of available packages from the PackageStates.php file.

protected loadPackageStates() : mixed

The result is stored in $this->packageStatesConfiguration.

Tags
throws
PackageStatesUnavailableException

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
throws
InvalidPackageManifestException
Return values
stdClass

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
throws
InvalidPackageStateException
throws
PackageStatesFileNotWritableException

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

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
stdClass

sortActivePackagesByDependencies()

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

sortPackageStatesConfigurationByDependency()

protected sortPackageStatesConfigurationByDependency(array<string|int, mixed> $packageStatesConfiguration) : array<int, PackageKey>
Parameters
$packageStatesConfiguration : array<string|int, mixed>
Tags
throws
UnexpectedValueException
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


        
On this page

Search results