PackageManager
class PackageManager (View source)
The default Flow Package Manager
Constants
PACKAGESTATE_FORMAT_VERSION |
The current format version for PackageStates.php files |
DEFAULT_PACKAGE_INFORMATION_CACHE_FILEPATH |
The default package states |
Properties
protected Bootstrap | $bootstrap | ||
protected PackageFactory | $packageFactory | ||
protected Dispatcher | $dispatcher | ||
protected array | $packages | Array of available packages, indexed by package key (case sensitive) |
|
protected array | $packageKeys | A translation table between lower cased and upper camel cased package keys |
|
protected array | $composerNameToPackageKeyMap | A map between ComposerName and PackageKey, only available when scanAvailablePackages is run |
|
protected string | $packagesBasePath | Absolute path leading to the various package directories |
|
protected string | $packageInformationCacheFilePath | ||
protected array | $packageStatesConfiguration | Package states configuration as stored in the PackageStates.php file |
|
protected array | $settings | ||
protected FlowPackageInterface[] | $flowPackages |
Methods
Inject settings into the package manager. Has to be called explicitly on object initialization as the package manager subpackage is excluded from proxy class building.
No description
Get only packages that implement the FlowPackageInterface for use in the Framework Array keys will be the respective package keys.
Returns true if a package is available (the package's files exist in the packages directory) or false if it's not.
Returns the base path for packages
Returns a PackageInterface object for the specified package.
Returns an array of PackageInterface objects of all available packages.
Returns an array of PackageInterface objects of all frozen packages.
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.
Returns an array of PackageInterface objects in the given array of packages that are of the specified package type.
Create a package, given the package key
Moves a package from one path to another.
Freezes a package
Tells if a package is frozen
Unfreezes a package
Refreezes a package
Rescans available packages, order and write a new PackageStates file.
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.
Load the current package states
Scans all directories in the packages directories for available packages.
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.
No description
Requires and registers all packages which were defined in packageStatesConfiguration
Registers a package under the given composer name with the configuration.
Takes the given packageStatesConfiguration, sorts it by dependencies, saves it and returns the ordered list
Save the given (ordered) array of package states data
Orders all packages by comparing their dependencies. By this, the packages and package configurations arrays holds all packages in the correct initialization order.
Collects the manifest data for all packages in the given package states array
Returns the correctly cased version of the given package key or false if no such package is available.
Resolves a Flow package key from a composer package name.
Check the conformance of the given package key
Resolves package key from Composer manifest
Derive a flow package key from the given information.
Emits a signal when package states have been changed (e.g. when a package was created)
Details
void
injectSettings(array $settings)
Inject settings into the package manager. Has to be called explicitly on object initialization as the package manager subpackage is excluded from proxy class building.
__construct(string $packageInformationCacheFilePath, string $packagesBasePath)
No description
void
initialize(Bootstrap $bootstrap)
Initializes the package manager
array
getFlowPackages()
internal |
Get only packages that implement the FlowPackageInterface for use in the Framework Array keys will be the respective package keys.
bool
isPackageAvailable(string $packageKey)
Returns true if a package is available (the package's files exist in the packages directory) or false if it's not.
string
getPackagesBasePath()
Returns the base path for packages
PackageInterface
getPackage(string $packageKey)
Returns a PackageInterface object for the specified package.
array
getAvailablePackages()
Returns an array of PackageInterface objects of all available packages.
A package is available, if the package directory contains valid meta information.
array
getFrozenPackages()
Returns an array of PackageInterface objects of all frozen packages.
A frozen package is not considered by file monitoring and provides some precompiled reflection data in order to improve performance.
array
getFilteredPackages(string $packageState = 'available', string $packageType = null)
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.
protected array
filterPackagesByType(array $packages, string $packageType)
Returns an array of PackageInterface objects in the given array of packages that are of the specified package type.
PackageInterface
createPackage(string $packageKey, array $manifest = [], string $packagesPath = null)
Create a package, given the package key
protected void
movePackage(string $fromAbsolutePath, string $toAbsolutePath)
Moves a package from one path to another.
void
freezePackage(string $packageKey)
Freezes a package
bool
isPackageFrozen(string $packageKey)
Tells if a package is frozen
void
unfreezePackage(string $packageKey)
Unfreezes a package
void
refreezePackage(string $packageKey)
Refreezes a package
array
rescanPackages()
Rescans available packages, order and write a new PackageStates file.
protected array
getCurrentPackageStates()
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 array
loadPackageStates()
Load the current package states
protected array
scanAvailablePackages()
Scans all directories in the packages directories for available packages.
For each package a Package object is created and stored in $this->packages.
protected Generator|null
findComposerPackagesInPath(string $startingDirectory)
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.
In case a "is-merged-repository" is found the traversal continues inside.
protected array
preparePackageStateConfiguration(string $packageKey, string $packagePath, array $composerManifest)
No description
protected void
registerPackagesFromConfiguration(array $packageStatesConfiguration)
Requires and registers all packages which were defined in packageStatesConfiguration
protected void
registerPackageFromStateConfiguration(string $composerName, array $packageStateConfiguration)
Registers a package under the given composer name with the configuration.
This uses the PackageFactory to create the Package instance and sets it to all relevant data arrays.
protected array
sortAndSavePackageStates(array $packageStates)
Takes the given packageStatesConfiguration, sorts it by dependencies, saves it and returns the ordered list
protected void
savePackageStates(array $orderedPackageStates)
Save the given (ordered) array of package states data
protected array
sortAvailablePackagesByDependencies(array $packageStates)
Orders all packages by comparing their dependencies. By this, the packages and package configurations arrays holds all packages in the correct initialization order.
protected array
collectPackageManifestData(array $packageStates)
Collects the manifest data for all packages in the given package states array
string|false
getCaseSensitivePackageKey(string $unknownCasedPackageKey)
Returns the correctly cased version of the given package key or false if no such package is available.
string
getPackageKeyFromComposerName(string $composerName)
Resolves a Flow package key from a composer package name.
bool
isPackageKeyValid(string $packageKey)
Check the conformance of the given package key
protected string
getPackageKeyFromManifest(array $manifest, string $packagePath)
Resolves package key from Composer manifest
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 string
derivePackageKey(string $composerName, string $packageType = null, string $packagePath = '', string $autoloadNamespace = null)
Derive a flow package key from the given information.
The order of importance is:
- package install path
- first found autoload namespace
- composer name
protected void
emitPackageStatesUpdated()
Emits a signal when package states have been changed (e.g. when a package was created)
The advice is not proxyable, so the signal is dispatched manually here.