PHP Class Neos\Flow\Package\PackageManager

Inheritance: implements Neos\Flow\Package\PackageManagerInterface
Exibir arquivo Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$activePackages array List of active packages as package key => package object
$bootstrap Neos\Flow\Core\Bootstrap
$composerNameToPackageKeyMap array A map between ComposerName and PackageKey, only available when scanAvailablePackages is run
$dispatcher Neos\Flow\SignalSlot\Dispatcher
$packageFactory PackageFactory
$packageKeys array A translation table between lower cased and upper camel cased package keys
$packageStatesConfiguration array Package states configuration as stored in the PackageStates.php file
$packageStatesPathAndFilename string
$packages array Array of available packages, indexed by package key (case sensitive)
$packagesBasePath string Absolute path leading to the various package directories
$settings array

Public Methods

Method Description
__construct ( string $packageStatesPathAndFilename = '' )
activatePackage ( string $packageKey ) : void Activates a package
createPackage ( string $packageKey, array $manifest = [], string $packagesPath = null ) : Neos\Flow\Package\PackageInterface Create a package, given the package key
deactivatePackage ( string $packageKey ) : void Deactivates a package
deletePackage ( string $packageKey ) : void Removes a package from registry and deletes it from filesystem
freezePackage ( string $packageKey ) : void Freezes a package
getActivePackages ( ) : array Returns an array of PackageInterface objects of all active packages.
getAvailablePackages ( ) : array Returns an array of PackageInterface objects of all available packages.
getCaseSensitivePackageKey ( string $unknownCasedPackageKey ) : mixed Returns the correctly cased version of the given package key or FALSE if no such package is available.
getFilteredPackages ( string $packageState = 'available', string $packagePath = null, string $packageType = null ) : array Returns an array of PackageInterface objects of all packages that match the given package state, path, and type filters. All three filters must match, if given.
getFrozenPackages ( ) : array Returns an array of PackageInterface objects of all frozen packages.
getPackage ( string $packageKey ) : Neos\Flow\Package\PackageInterface Returns a PackageInterface object for the specified package.
getPackageKeyFromComposerName ( string $composerName ) : string Resolves a Flow package key from a composer package name.
getPackageVersion ( string $composerName ) : string Get the package version of the given package Return normalized package version.
getPackagesBasePath ( ) : string Returns the base path for packages
initialize ( Bootstrap $bootstrap ) : void Initializes the package manager
injectSettings ( array $settings ) : void
isPackageActive ( string $packageKey ) : boolean Returns TRUE if a package is activated or FALSE if it's not.
isPackageAvailable ( string $packageKey ) : boolean 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!
isPackageFrozen ( string $packageKey ) : boolean Tells if a package is frozen
isPackageKeyValid ( string $packageKey ) : boolean Check the conformance of the given package key
refreezePackage ( string $packageKey ) : void Refreezes a package
rescanPackages ( boolean $reloadPackageStates = true ) : array Rescans available packages, order and write a new PackageStates file.
unfreezePackage ( string $packageKey ) : void Unfreezes a package

Protected Methods

Method Description
buildActivePackageRelativePath ( string $inactivePackagePath ) : string Build the relative path to store an active package from the given inactive path
buildInactivePackageRelativePath ( string $packagePath ) : string Build the relative path to store a deactivated package based on the package.
collectPackageManifestData ( array $packageStates ) : array Collects the manifest data for all packages in the given package states array
derivePackageKey ( string $composerName, string $packageType = null, string $packagePath = null, string $autoloadNamespace = null ) : string Derive a flow package key from the given information.
emitPackageStatesUpdated ( ) : void Emits a signal when package states have been changed (e.g. when a package was created or activated)
filterPackagesByPath ( array &$packages, string $filterPath ) : array Returns an array of PackageInterface objects in the given array of packages that are in the specified Package Path
filterPackagesByType ( array &$packages, string $packageType ) : array Returns an array of PackageInterface objects in the given array of packages that are of the specified package type.
findComposerPackagesInPath ( string $startingDirectory ) : Generator Recursively traverses directories from the given starting points and returns all folder paths that contain a composer.json and which does NOT have the key "extra.neos.is-merged-repository" set, as that indicates a composer package that joins several "real" packages together.
getCurrentPackageStates ( ) : array Loads the states of available packages from the PackageStates.php file and initialises a package scan if the file was not found or the configuration format was not current.
getPackageKeyFromManifest ( array $manifest, string $packagePath ) : string Resolves package key from Composer manifest
loadPackageStates ( ) : array Load the current package states
movePackage ( string $fromAbsolutePath, string $toAbsolutePath ) : void Moves a package from one path to another.
movePackageToActivatedPackages ( string $inactivePackagePath ) : void Moves a package from the given inactive package path to the active package path.
movePackageToDeactivatedPackages ( string $packagePath ) : void Moves a package from the regular package path to the inactive packages directory.
preparePackageStateConfiguration ( string $packageKey, string $packagePath, array $composerManifest, string $state = self::PACKAGE_STATE_ACTIVE ) : array
recoverStateFromConfiguration ( array $packageStatesConfiguration ) : array Recover previous package state from given packageStatesConfiguration to be used after rescanning packages.
registerPackageFromStateConfiguration ( string $composerName, array $packageStateConfiguration ) : void Registers a package under the given composer name with the configuration.
registerPackagesFromConfiguration ( array $packageStatesConfiguration ) Requires and registers all packages which were defined in packageStatesConfiguration
savePackageStates ( array $orderedPackageStates ) Save the given (ordered) array of package states data
scanAvailablePackages ( array $previousPackageStatesConfiguration ) : array Scans all directories in the packages directories for available packages.
sortAndSavePackageStates ( array $packageStates ) : array Takes the given packageStatesConfiguration, sorts it by dependencies, saves it and returns the ordered list
sortAvailablePackagesByDependencies ( array $packageStates ) : array Orders all packages by comparing their dependencies. By this, the packages and package configurations arrays holds all packages in the correct initialization order.
unregisterPackage ( Neos\Flow\Package\PackageInterface $package ) : void Unregisters a package from the list of available packages

Method Details

__construct() public method

public __construct ( string $packageStatesPathAndFilename = '' )
$packageStatesPathAndFilename string

activatePackage() public method

Activates a package
public activatePackage ( string $packageKey ) : void
$packageKey string The package to activate
return void

buildActivePackageRelativePath() protected method

Build the relative path to store an active package from the given inactive path
protected buildActivePackageRelativePath ( string $inactivePackagePath ) : string
$inactivePackagePath string
return string

buildInactivePackageRelativePath() protected method

Build the relative path to store a deactivated package based on the package.
protected buildInactivePackageRelativePath ( string $packagePath ) : string
$packagePath string absolute path to the package
return string

collectPackageManifestData() protected method

Collects the manifest data for all packages in the given package states array
protected collectPackageManifestData ( array $packageStates ) : array
$packageStates array
return array

createPackage() public method

Create a package, given the package key
public createPackage ( string $packageKey, array $manifest = [], string $packagesPath = null ) : Neos\Flow\Package\PackageInterface
$packageKey string The package key of the new package
$manifest array A composer manifest as associative array. This is a preparation for the signature change in Flow 4.0. If you use this argument, then $packageMetaData and $packageType will be ignored.
$packagesPath string If specified, the package will be created in this path, otherwise the default "Application" directory is used
return Neos\Flow\Package\PackageInterface The newly created package

deactivatePackage() public method

Deactivates a package
public deactivatePackage ( string $packageKey ) : void
$packageKey string The package to deactivate
return void

deletePackage() public method

Removes a package from registry and deletes it from filesystem
public deletePackage ( string $packageKey ) : void
$packageKey string package to remove
return void

derivePackageKey() protected method

The order of importance is: - package install path - first found autoload namespace - composer name
protected derivePackageKey ( string $composerName, string $packageType = null, string $packagePath = null, string $autoloadNamespace = null ) : string
$composerName string
$packageType string
$packagePath string
$autoloadNamespace string
return string

emitPackageStatesUpdated() protected method

The advice is not proxyable, so the signal is dispatched manually here.
protected emitPackageStatesUpdated ( ) : void
return void

filterPackagesByPath() protected method

Returns an array of PackageInterface objects in the given array of packages that are in the specified Package Path
protected filterPackagesByPath ( array &$packages, string $filterPath ) : array
$packages array Array of PackageInterface to be filtered
$filterPath string Filter out anything that's not in this path
return array

filterPackagesByType() protected method

Returns an array of PackageInterface objects in the given array of packages that are of the specified package type.
protected filterPackagesByType ( array &$packages, string $packageType ) : array
$packages array Array of PackageInterface objects to be filtered
$packageType string Filter out anything that's not of this packageType
return array

findComposerPackagesInPath() protected method

In case a "is-merged-repository" is found the traversal continues inside.
protected findComposerPackagesInPath ( string $startingDirectory ) : Generator
$startingDirectory string
return Generator

freezePackage() public method

Freezes a package
public freezePackage ( string $packageKey ) : void
$packageKey string The package to freeze
return void

getActivePackages() public method

A package is active, if it is available and has been activated in the package manager settings.
public getActivePackages ( ) : array
return array

getAvailablePackages() public method

A package is available, if the package directory contains valid meta information.
public getAvailablePackages ( ) : array
return array

getCaseSensitivePackageKey() public method

Returns the correctly cased version of the given package key or FALSE if no such package is available.
public getCaseSensitivePackageKey ( string $unknownCasedPackageKey ) : mixed
$unknownCasedPackageKey string The package key to convert
return mixed The upper camel cased package key or FALSE if no such package exists

getCurrentPackageStates() protected method

Loads the states of available packages from the PackageStates.php file and initialises a package scan if the file was not found or the configuration format was not current.
protected getCurrentPackageStates ( ) : array
return array

getFilteredPackages() public method

Returns an array of PackageInterface objects of all packages that match the given package state, path, and type filters. All three filters must match, if given.
public getFilteredPackages ( string $packageState = 'available', string $packagePath = null, string $packageType = null ) : array
$packageState string defaults to available
$packagePath string
$packageType string
return array

getFrozenPackages() public method

A frozen package is not considered by file monitoring and provides some precompiled reflection data in order to improve performance.
public getFrozenPackages ( ) : array
return array

getPackage() public method

Returns a PackageInterface object for the specified package.
public getPackage ( string $packageKey ) : Neos\Flow\Package\PackageInterface
$packageKey string
return Neos\Flow\Package\PackageInterface The requested package object

getPackageKeyFromComposerName() public method

Resolves a Flow package key from a composer package name.
public getPackageKeyFromComposerName ( string $composerName ) : string
$composerName string
return string

getPackageKeyFromManifest() protected method

If it is a Flow 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
protected getPackageKeyFromManifest ( array $manifest, string $packagePath ) : string
$manifest array
$packagePath string
return string

getPackageVersion() public static method

Get the package version of the given package Return normalized package version.
See also: https://getcomposer.org/doc/04-schema.md#version
public static getPackageVersion ( string $composerName ) : string
$composerName string
return string

getPackagesBasePath() public method

Returns the base path for packages
public getPackagesBasePath ( ) : string
return string

initialize() public method

Initializes the package manager
public initialize ( Bootstrap $bootstrap ) : void
$bootstrap Neos\Flow\Core\Bootstrap The current bootstrap
return void

injectSettings() public method

public injectSettings ( array $settings ) : void
$settings array
return void

isPackageActive() public method

Returns TRUE if a package is activated or FALSE if it's not.
public isPackageActive ( string $packageKey ) : boolean
$packageKey string The key of the package to check
return boolean TRUE if package is active, otherwise FALSE

isPackageAvailable() public method

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 ) : boolean
$packageKey string The key of the package to check
return boolean TRUE if the package is available, otherwise FALSE

isPackageFrozen() public method

Tells if a package is frozen
public isPackageFrozen ( string $packageKey ) : boolean
$packageKey string The package to check
return boolean

isPackageKeyValid() public method

Check the conformance of the given package key
public isPackageKeyValid ( string $packageKey ) : boolean
$packageKey string The package key to validate
return boolean If the package key is valid, returns TRUE otherwise FALSE

loadPackageStates() protected method

Load the current package states
protected loadPackageStates ( ) : array
return array

movePackage() protected method

Moves a package from one path to another.
protected movePackage ( string $fromAbsolutePath, string $toAbsolutePath ) : void
$fromAbsolutePath string
$toAbsolutePath string
return void

movePackageToActivatedPackages() protected method

Moves a package from the given inactive package path to the active package path.
protected movePackageToActivatedPackages ( string $inactivePackagePath ) : void
$inactivePackagePath string
return void

movePackageToDeactivatedPackages() protected method

Moves a package from the regular package path to the inactive packages directory.
protected movePackageToDeactivatedPackages ( string $packagePath ) : void
$packagePath string absolute path to the package
return void

preparePackageStateConfiguration() protected method

protected preparePackageStateConfiguration ( string $packageKey, string $packagePath, array $composerManifest, string $state = self::PACKAGE_STATE_ACTIVE ) : array
$packageKey string
$packagePath string
$composerManifest array
$state string
return array

recoverStateFromConfiguration() protected method

Recover previous package state from given packageStatesConfiguration to be used after rescanning packages.
protected recoverStateFromConfiguration ( array $packageStatesConfiguration ) : array
$packageStatesConfiguration array
return array

refreezePackage() public method

Refreezes a package
public refreezePackage ( string $packageKey ) : void
$packageKey string The package to refreeze
return void

registerPackageFromStateConfiguration() protected method

This uses the PackageFactory to create the Package instance and sets it to all relevant data arrays.
protected registerPackageFromStateConfiguration ( string $composerName, array $packageStateConfiguration ) : void
$composerName string
$packageStateConfiguration array
return void

registerPackagesFromConfiguration() protected method

Requires and registers all packages which were defined in packageStatesConfiguration
protected registerPackagesFromConfiguration ( array $packageStatesConfiguration )
$packageStatesConfiguration array

rescanPackages() public method

Rescans available packages, order and write a new PackageStates file.
public rescanPackages ( boolean $reloadPackageStates = true ) : array
$reloadPackageStates boolean Should the package states be loaded before scanning or use the current configuration
return array The found and sorted package states.

savePackageStates() protected method

Save the given (ordered) array of package states data
protected savePackageStates ( array $orderedPackageStates )
$orderedPackageStates array

scanAvailablePackages() protected method

For each package a Package object is created and stored in $this->packages.
protected scanAvailablePackages ( array $previousPackageStatesConfiguration ) : array
$previousPackageStatesConfiguration array Existing package state configuration
return array

sortAndSavePackageStates() protected method

Takes the given packageStatesConfiguration, sorts it by dependencies, saves it and returns the ordered list
protected sortAndSavePackageStates ( array $packageStates ) : array
$packageStates array
return array

sortAvailablePackagesByDependencies() protected method

Orders all packages by comparing their dependencies. By this, the packages and package configurations arrays holds all packages in the correct initialization order.
protected sortAvailablePackagesByDependencies ( array $packageStates ) : array
$packageStates array The unordered package states
return array ordered package states.

unfreezePackage() public method

Unfreezes a package
public unfreezePackage ( string $packageKey ) : void
$packageKey string The package to unfreeze
return void

unregisterPackage() protected method

Unregisters a package from the list of available packages
protected unregisterPackage ( Neos\Flow\Package\PackageInterface $package ) : void
$package Neos\Flow\Package\PackageInterface The package to be unregistered
return void

Property Details

$activePackages protected_oe property

List of active packages as package key => package object
protected array $activePackages
return array

$bootstrap protected_oe property

protected Bootstrap,Neos\Flow\Core $bootstrap
return Neos\Flow\Core\Bootstrap

$composerNameToPackageKeyMap protected_oe property

A map between ComposerName and PackageKey, only available when scanAvailablePackages is run
protected array $composerNameToPackageKeyMap
return array

$dispatcher protected_oe property

protected Dispatcher,Neos\Flow\SignalSlot $dispatcher
return Neos\Flow\SignalSlot\Dispatcher

$packageFactory protected_oe property

protected PackageFactory,Neos\Flow\Package $packageFactory
return PackageFactory

$packageKeys protected_oe property

A translation table between lower cased and upper camel cased package keys
protected array $packageKeys
return array

$packageStatesConfiguration protected_oe property

Package states configuration as stored in the PackageStates.php file
protected array $packageStatesConfiguration
return array

$packageStatesPathAndFilename protected_oe property

protected string $packageStatesPathAndFilename
return string

$packages protected_oe property

Array of available packages, indexed by package key (case sensitive)
protected array $packages
return array

$packagesBasePath protected_oe property

Absolute path leading to the various package directories
protected string $packagesBasePath
return string

$settings protected_oe property

protected array $settings
return array