TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
PackageManager Class Reference
Inheritance diagram for PackageManager:
SingletonInterface FailsafePackageManager UnitTestPackageManager

Public Member Functions

 __construct ()
 
 injectCoreCache (\TYPO3\CMS\Core\Cache\Frontend\PhpFrontend $coreCache)
 
 injectDependencyResolver (DependencyResolver $dependencyResolver)
 
 initialize ()
 
 scanAvailablePackages ()
 
 registerPackage (PackageInterface $package)
 
 getPackageKeyFromComposerName ($composerName)
 
 getPackage ($packageKey)
 
 isPackageAvailable ($packageKey)
 
 isPackageActive ($packageKey)
 
 deactivatePackage ($packageKey)
 
 activatePackage ($packageKey)
 
 activatePackageDuringRuntime ($packageKey)
 
 deletePackage ($packageKey)
 
 getActivePackages ()
 
 isPackageKeyValid ($packageKey)
 
 getAvailablePackages ()
 
 unregisterPackage (PackageInterface $package)
 
 getComposerManifest ($manifestPath)
 

Protected Member Functions

 getCacheIdentifier ()
 
 getCacheEntryIdentifier ()
 
 saveToPackageCache ()
 
 loadPackageManagerStatesFromCache ()
 
 loadPackageStates ()
 
 initializePackageObjects ()
 
 registerActivePackage (PackageInterface $package)
 
 initializeCompatibilityLoadedExtArray ()
 
 registerPackageDuringRuntime ($packageKey)
 
 registerPackagesFromConfiguration (array $packages, $registerOnlyNewPackages=false, $packageStatesHasChanged=false)
 
 unregisterPackageByPackageKey ($packageKey)
 
 registerTransientClassLoadingInformationForPackage (PackageInterface $package)
 
 sortActivePackagesByDependencies ()
 
 resolvePackageDependencies ($packageConfig)
 
 getSuggestionArrayForPackage ($packageKey)
 
 sortAndSavePackageStates ()
 
 getExtensionEmConf ($packagePath)
 
 mapExtensionManagerConfigurationToComposerManifest ($packageKey, array $extensionManagerConfiguration,\stdClass $composerManifest)
 
 setComposerManifestValueIfEmpty (\stdClass $manifest, $property, $value)
 
 getDependencyArrayForPackage ($packageKey, array &$dependentPackageKeys=[], array $trace=[])
 
 getPackageKeyFromManifest ($manifest, $packagePath)
 
 getPackageBasePaths ()
 

Protected Attributes

 $dependencyResolver
 
 $coreCache
 
 $cacheIdentifier
 
 $packagesBasePaths = []
 
 $packageAliasMap = []
 
 $runtimeActivatedPackages = []
 
 $packagesBasePath = PATH_site
 
 $packages = []
 
 $composerNameToPackageKeyMap = []
 
 $activePackages = []
 
 $packageStatesPathAndFilename
 
 $packageStatesConfiguration = []
 

Detailed Description

The default TYPO3 Package Manager Adapted from FLOW for TYPO3 CMS

Definition at line 32 of file PackageManager.php.

Constructor & Destructor Documentation

__construct ( )

Constructor

Definition at line 102 of file PackageManager.php.

Member Function Documentation

activatePackageDuringRuntime (   $packageKey)

Enables packages during runtime, but no class aliases will be available

Parameters
string$packageKey

Definition at line 599 of file PackageManager.php.

References $GLOBALS, PackageManager\registerPackageDuringRuntime(), and PackageManager\registerTransientClassLoadingInformationForPackage().

deactivatePackage (   $packageKey)

Deactivates a package and updates the packagestates configuration

Parameters
string$packageKey
Exceptions
ExceptionPackageStatesFileNotWritableException
ExceptionProtectedPackageKeyException
ExceptionUnknownPackageException

Definition at line 550 of file PackageManager.php.

References PackageManager\getPackage(), PackageManager\isPackageActive(), PackageManager\sortActivePackagesByDependencies(), and PackageManager\sortAndSavePackageStates().

Referenced by PackageManager\deletePackage().

deletePackage (   $packageKey)

Removes a package from the file system.

Parameters
string$packageKey
Exceptions
Exception
ExceptionInvalidPackageStateException
ExceptionProtectedPackageKeyException
ExceptionUnknownPackageException

Definition at line 631 of file PackageManager.php.

References PackageManager\deactivatePackage(), PackageManager\getPackage(), PackageManager\isPackageActive(), PackageManager\isPackageAvailable(), GeneralUtility\rmdir(), PackageManager\sortAndSavePackageStates(), and PackageManager\unregisterPackage().

getActivePackages ( )

Returns an array of objects of all active packages. A package is active, if it is available and has been activated in the package manager settings. This method returns runtime activated packages too

Returns
PackageInterface[]

Definition at line 664 of file PackageManager.php.

References PackageManager\getPackage().

getAvailablePackages ( )

Returns an array of objects of all available packages. A package is available, if the package directory contains valid meta information.

Returns
PackageInterface[] Array of PackageInterface

Definition at line 797 of file PackageManager.php.

References PackageManager\$packages.

getCacheEntryIdentifier ( )
protected
getCacheIdentifier ( )
protected
Returns
string

Definition at line 143 of file PackageManager.php.

References PackageManager\$cacheIdentifier.

Referenced by PackageManager\getCacheEntryIdentifier().

getComposerManifest (   $manifestPath)

Returns contents of Composer manifest as a stdObject

Parameters
string$manifestPath
Returns
Exceptions
ExceptionInvalidPackageManifestException

Definition at line 848 of file PackageManager.php.

References PackageManager\getExtensionEmConf(), and PackageManager\mapExtensionManagerConfigurationToComposerManifest().

Referenced by Package\__construct(), PackageManager\registerPackageDuringRuntime(), and PackageManager\scanAvailablePackages().

getDependencyArrayForPackage (   $packageKey,
array &  $dependentPackageKeys = [],
array  $trace = [] 
)
protected

Returns an array of dependent package keys for the given package. It will do this recursively, so dependencies of dependant packages will also be in the result.

Parameters
string$packageKeyThe package key to fetch the dependencies for
array$dependentPackageKeys
array$traceAn array of already visited package keys, to detect circular dependencies
Returns
array|NULL An array of direct or indirect dependant packages
Exceptions
ExceptionInvalidPackageKeyException

Definition at line 981 of file PackageManager.php.

Referenced by PackageManager\resolvePackageDependencies().

getExtensionEmConf (   $packagePath)
protected

Fetches MetaData information from ext_emconf.php, used for resolving dependencies as well.

Parameters
string$packagePath
Returns
array
Exceptions
ExceptionInvalidPackageManifestException

Definition at line 877 of file PackageManager.php.

References $EM_CONF.

Referenced by PackageManager\getComposerManifest().

getPackage (   $packageKey)

Returns a PackageInterface object for the specified package. A package is available, if the package directory contains valid MetaData information.

Parameters
string$packageKey
Returns
PackageInterface The requested package object
Exceptions
ExceptionUnknownPackageException if the specified package is not known

Definition at line 503 of file PackageManager.php.

References PackageManager\isPackageAvailable().

Referenced by PackageManager\activatePackage(), PackageManager\deactivatePackage(), PackageManager\deletePackage(), PackageManager\getActivePackages(), and PackageManager\unregisterPackageByPackageKey().

getPackageBasePaths ( )
protected

The order of paths is crucial for allowing overriding of system extension by local extensions. Pay attention if you change order of the paths here.

Returns
array

Definition at line 1038 of file PackageManager.php.

getPackageKeyFromComposerName (   $composerName)

Resolves a TYPO3 package key from a composer package name.

Parameters
string$composerName
Returns
string

Definition at line 481 of file PackageManager.php.

getPackageKeyFromManifest (   $manifest,
  $packagePath 
)
protected

Resolves package key from Composer manifest

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
object$manifest
string$packagePath
Exceptions
ExceptionInvalidPackageManifestException
Returns
string

Definition at line 1018 of file PackageManager.php.

Referenced by PackageManager\registerPackageDuringRuntime(), and PackageManager\scanAvailablePackages().

getSuggestionArrayForPackage (   $packageKey)
protected

Returns an array of suggested package keys for the given package.

Parameters
string$packageKeyThe package key to fetch the suggestions for
Returns
array|NULL An array of directly suggested packages

Definition at line 723 of file PackageManager.php.

References MetaData\CONSTRAINT_TYPE_SUGGESTS.

Referenced by PackageManager\resolvePackageDependencies().

initializeCompatibilityLoadedExtArray ( )
protected

Initializes a backwards compatibility $GLOBALS['TYPO3_LOADED_EXT'] array

Returns
void

Definition at line 294 of file PackageManager.php.

References $GLOBALS.

Referenced by PackageManager\initialize(), and PackageManager\sortAndSavePackageStates().

initializePackageObjects ( )
protected

Initializes activePackages property

Saves PackageStates.php if list of required extensions has changed.

Returns
void

Definition at line 256 of file PackageManager.php.

References PackageManager\$activePackages, PackageManager\registerActivePackage(), and PackageManager\sortAndSavePackageStates().

Referenced by PackageManager\initialize().

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

Definition at line 110 of file PackageManager.php.

References PackageManager\$coreCache.

injectDependencyResolver ( DependencyResolver  $dependencyResolver)
Parameters
DependencyResolver

Definition at line 118 of file PackageManager.php.

References PackageManager\$dependencyResolver.

isPackageActive (   $packageKey)

Returns TRUE if a package is activated or FALSE if it's not.

Parameters
string$packageKeyThe key of the package to check
Returns
bool TRUE if package is active, otherwise FALSE

Definition at line 537 of file PackageManager.php.

Referenced by PackageManager\activatePackage(), PackageManager\deactivatePackage(), and PackageManager\deletePackage().

isPackageAvailable (   $packageKey)

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!

Parameters
string$packageKeyThe key of the package to check
Returns
bool TRUE if the package is available, otherwise FALSE

Definition at line 522 of file PackageManager.php.

Referenced by PackageManager\deletePackage(), PackageManager\getPackage(), PackageManager\registerPackage(), PackageManager\registerPackagesFromConfiguration(), and PackageManager\unregisterPackage().

isPackageKeyValid (   $packageKey)

Check the conformance of the given package key

Parameters
string$packageKeyThe package key to validate
Returns
bool If the package key is valid, returns TRUE otherwise FALSE

Definition at line 785 of file PackageManager.php.

References PackageInterface\PATTERN_MATCH_EXTENSIONKEY, and PackageInterface\PATTERN_MATCH_PACKAGEKEY.

Referenced by Package\__construct(), and PackageManager\scanAvailablePackages().

loadPackageManagerStatesFromCache ( )
protected

Attempts to load the package manager states from cache

Exceptions
ExceptionPackageManagerCacheUnavailableException

Definition at line 195 of file PackageManager.php.

References $GLOBALS, and PackageManager\getCacheEntryIdentifier().

Referenced by PackageManager\initialize().

loadPackageStates ( )
protected

Loads the states of available packages from the PackageStates.php file. The result is stored in $this->packageStatesConfiguration.

Exceptions
ExceptionPackageStatesUnavailableException
Returns
void

Definition at line 222 of file PackageManager.php.

References PackageManager\$activePackages, and PackageManager\registerPackagesFromConfiguration().

Referenced by PackageManager\initialize().

mapExtensionManagerConfigurationToComposerManifest (   $packageKey,
array  $extensionManagerConfiguration,
\stdClass  $composerManifest 
)
protected

Fetches information from ext_emconf.php and maps it so it is treated as it would come from composer.json

Parameters
string$packageKey
array$extensionManagerConfiguration
\stdClass$composerManifest
Returns
Exceptions
ExceptionInvalidPackageManifestException

Definition at line 901 of file PackageManager.php.

References PackageManager\setComposerManifestValueIfEmpty().

Referenced by PackageManager\getComposerManifest().

registerPackage ( PackageInterface  $package)

Register a native TYPO3 package

Parameters
PackageInterface$packageThe Package to be registered
Returns
PackageInterface
Exceptions
ExceptionInvalidPackageStateException
ExceptionPackageStatesFileNotWritableException

Definition at line 437 of file PackageManager.php.

References PackageInterface\getPackageKey(), PackageInterface\getPackageReplacementKeys(), and PackageManager\isPackageAvailable().

Referenced by PackageManager\registerPackageDuringRuntime(), and PackageManager\registerPackagesFromConfiguration().

registerPackageDuringRuntime (   $packageKey)
protected
registerPackagesFromConfiguration ( array  $packages,
  $registerOnlyNewPackages = false,
  $packageStatesHasChanged = false 
)
protected

Requires and registers all packages which were defined in packageStatesConfiguration

Parameters
array$packages
bool$registerOnlyNewPackages
bool$packageStatesHasChanged
Exceptions
ExceptionInvalidPackageStateException
ExceptionPackageStatesFileNotWritableException

Definition at line 392 of file PackageManager.php.

References PackageManager\isPackageAvailable(), PackageManager\registerPackage(), PathUtility\sanitizeTrailingSeparator(), PackageManager\sortAndSavePackageStates(), and PackageManager\unregisterPackageByPackageKey().

Referenced by PackageManager\loadPackageStates(), and PackageManager\scanAvailablePackages().

registerTransientClassLoadingInformationForPackage ( PackageInterface  $package)
protected
resolvePackageDependencies (   $packageConfig)
protected

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.

Parameters
$packageConfig
Returns
array

Definition at line 707 of file PackageManager.php.

References PackageManager\getDependencyArrayForPackage(), and PackageManager\getSuggestionArrayForPackage().

Referenced by PackageManager\sortActivePackagesByDependencies().

saveToPackageCache ( )
protected
scanAvailablePackages ( )

Scans all directories in the packages directories for available packages. For each package a Package object is created and stored in $this->packages.

Returns
void

Definition at line 306 of file PackageManager.php.

References PackageManager\$packages, PackageManager\getComposerManifest(), PackageManager\getPackageKeyFromManifest(), PackageManager\isPackageKeyValid(), and PackageManager\registerPackagesFromConfiguration().

Referenced by UnitTestPackageManager\initialize(), and FailsafePackageManager\loadPackageStates().

setComposerManifestValueIfEmpty ( \stdClass  $manifest,
  $property,
  $value 
)
protected
Parameters
\stdClass$manifest
string$property
mixed$value
Returns

Definition at line 961 of file PackageManager.php.

Referenced by PackageManager\mapExtensionManagerConfigurationToComposerManifest().

sortActivePackagesByDependencies ( )
protected

Orders all active packages by comparing their dependencies. By this, the packages and package configurations arrays holds all packages in the correct initialization order.

Returns
array

Definition at line 683 of file PackageManager.php.

References PackageManager\registerActivePackage(), and PackageManager\resolvePackageDependencies().

Referenced by PackageManager\deactivatePackage(), and PackageManager\sortAndSavePackageStates().

unregisterPackage ( PackageInterface  $package)

Unregisters a package from the list of available packages

Parameters
PackageInterface$packageThe package to be unregistered
Returns
void
Exceptions
ExceptionInvalidPackageStateException

Definition at line 809 of file PackageManager.php.

References PackageInterface\getPackageKey(), PackageManager\isPackageAvailable(), and PackageManager\unregisterPackageByPackageKey().

Referenced by PackageManager\deletePackage().

unregisterPackageByPackageKey (   $packageKey)
protected

Unregisters a package from the list of available packages

Parameters
string$packageKeyPackage Key of the package to be unregistered
Returns
void

Definition at line 460 of file PackageManager.php.

References PackageManager\getPackage().

Referenced by PackageManager\registerPackagesFromConfiguration(), and PackageManager\unregisterPackage().

Member Data Documentation

$activePackages = []
protected
$cacheIdentifier
protected
$composerNameToPackageKeyMap = []
protected

Definition at line 80 of file PackageManager.php.

Referenced by PackageManager\saveToPackageCache().

$coreCache
protected

Definition at line 42 of file PackageManager.php.

Referenced by PackageManager\injectCoreCache().

$dependencyResolver
protected

Definition at line 37 of file PackageManager.php.

Referenced by PackageManager\injectDependencyResolver().

$packageAliasMap = []
protected

Definition at line 57 of file PackageManager.php.

Referenced by PackageManager\saveToPackageCache().

$packages = []
protected
$packagesBasePath = PATH_site
protected

Definition at line 68 of file PackageManager.php.

$packagesBasePaths = []
protected

Definition at line 52 of file PackageManager.php.

$packageStatesConfiguration = []
protected

Definition at line 97 of file PackageManager.php.

Referenced by PackageManager\saveToPackageCache().

$packageStatesPathAndFilename
protected

Definition at line 91 of file PackageManager.php.

$runtimeActivatedPackages = []
protected

Definition at line 62 of file PackageManager.php.