PHP Class Neos\Flow\Package\PackageManager

Inheritance: implements Neos\Flow\Package\PackageManagerInterface
Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Свойство 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

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode 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 méthode

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

activatePackage() public méthode

Activates a package
public activatePackage ( string $packageKey ) : void
$packageKey string The package to activate
Résultat void

buildActivePackageRelativePath() protected méthode

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

buildInactivePackageRelativePath() protected méthode

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
Résultat string

collectPackageManifestData() protected méthode

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

createPackage() public méthode

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
Résultat Neos\Flow\Package\PackageInterface The newly created package

deactivatePackage() public méthode

Deactivates a package
public deactivatePackage ( string $packageKey ) : void
$packageKey string The package to deactivate
Résultat void

deletePackage() public méthode

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

derivePackageKey() protected méthode

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
Résultat string

emitPackageStatesUpdated() protected méthode

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

filterPackagesByPath() protected méthode

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
Résultat array

filterPackagesByType() protected méthode

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
Résultat array

findComposerPackagesInPath() protected méthode

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

freezePackage() public méthode

Freezes a package
public freezePackage ( string $packageKey ) : void
$packageKey string The package to freeze
Résultat void

getActivePackages() public méthode

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

getAvailablePackages() public méthode

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

getCaseSensitivePackageKey() public méthode

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
Résultat mixed The upper camel cased package key or FALSE if no such package exists

getCurrentPackageStates() protected méthode

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
Résultat array

getFilteredPackages() public méthode

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
Résultat array

getFrozenPackages() public méthode

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

getPackage() public méthode

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

getPackageKeyFromComposerName() public méthode

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

getPackageKeyFromManifest() protected méthode

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
Résultat string

getPackageVersion() public static méthode

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
Résultat string

getPackagesBasePath() public méthode

Returns the base path for packages
public getPackagesBasePath ( ) : string
Résultat string

initialize() public méthode

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

injectSettings() public méthode

public injectSettings ( array $settings ) : void
$settings array
Résultat void

isPackageActive() public méthode

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
Résultat boolean TRUE if package is active, otherwise FALSE

isPackageAvailable() public méthode

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
Résultat boolean TRUE if the package is available, otherwise FALSE

isPackageFrozen() public méthode

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

isPackageKeyValid() public méthode

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

loadPackageStates() protected méthode

Load the current package states
protected loadPackageStates ( ) : array
Résultat array

movePackage() protected méthode

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

movePackageToActivatedPackages() protected méthode

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

movePackageToDeactivatedPackages() protected méthode

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
Résultat void

preparePackageStateConfiguration() protected méthode

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

recoverStateFromConfiguration() protected méthode

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

refreezePackage() public méthode

Refreezes a package
public refreezePackage ( string $packageKey ) : void
$packageKey string The package to refreeze
Résultat void

registerPackageFromStateConfiguration() protected méthode

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
Résultat void

registerPackagesFromConfiguration() protected méthode

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

rescanPackages() public méthode

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
Résultat array The found and sorted package states.

savePackageStates() protected méthode

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

scanAvailablePackages() protected méthode

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

sortAndSavePackageStates() protected méthode

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

sortAvailablePackagesByDependencies() protected méthode

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
Résultat array ordered package states.

unfreezePackage() public méthode

Unfreezes a package
public unfreezePackage ( string $packageKey ) : void
$packageKey string The package to unfreeze
Résultat void

unregisterPackage() protected méthode

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
Résultat void

Property Details

$activePackages protected_oe property

List of active packages as package key => package object
protected array $activePackages
Résultat array

$bootstrap protected_oe property

protected Bootstrap,Neos\Flow\Core $bootstrap
Résultat Neos\Flow\Core\Bootstrap

$composerNameToPackageKeyMap protected_oe property

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

$dispatcher protected_oe property

protected Dispatcher,Neos\Flow\SignalSlot $dispatcher
Résultat Neos\Flow\SignalSlot\Dispatcher

$packageFactory protected_oe property

protected PackageFactory,Neos\Flow\Package $packageFactory
Résultat PackageFactory

$packageKeys protected_oe property

A translation table between lower cased and upper camel cased package keys
protected array $packageKeys
Résultat array

$packageStatesConfiguration protected_oe property

Package states configuration as stored in the PackageStates.php file
protected array $packageStatesConfiguration
Résultat array

$packageStatesPathAndFilename protected_oe property

protected string $packageStatesPathAndFilename
Résultat string

$packages protected_oe property

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

$packagesBasePath protected_oe property

Absolute path leading to the various package directories
protected string $packagesBasePath
Résultat string

$settings protected_oe property

protected array $settings
Résultat array