PHP Class Puli\Manager\Api\Repository\PathMapping

The filesystem paths are passed in the form of *path references* that are either paths relative to the module's root directory or paths relative to another modules's root directory prefixed with @vendor/module:, where "vendor/module" is the name of the referenced module. The path references are turned into absolute filesystem paths when {@link load()} is called.
Since: 1.0
Author: Bernhard Schussek ([email protected])
Afficher le fichier Open project: puli/manager Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( string $repositoryPath, string | string[] $pathReferences ) Creates a new path mapping.
addConflict ( Puli\Manager\Api\Repository\PathConflict $conflict ) Adds a conflict to the mapping.
getConflictingMappings ( ) : PathMapping[] Returns all conflicting path mappings.
getConflictingModules ( ) : ModuleList Returns all modules with conflicting path mappings.
getConflicts ( ) : Puli\Manager\Api\Repository\PathConflict[] Returns the conflicts of the mapping.
getContainingModule ( ) : Puli\Manager\Api\Module\Module Returns the module that contains the mapping.
getFilesystemPaths ( ) : string[] Returns the referenced filesystem paths.
getLoadErrors ( ) : Exceptio\Exception[] Returns the errors that occurred during loading of the mapping.
getPathReferences ( ) : string[] Returns the path references.
getRepositoryPath ( ) : string Returns the repository path.
getState ( ) : integer Returns the state of the mapping.
isConflicting ( ) : boolean Returns whether the mapping conflicts with a mapping in another module.
isEnabled ( ) : boolean Returns whether the mapping is enabled.
isLoaded ( ) : boolean Returns whether the mapping is loaded.
isNotFound ( ) : boolean Returns whether the path referenced by the mapping was not found.
listPathMappings ( ) : string[] Lists all filesystem path to repository path mappings of this mapping.
listRepositoryPaths ( ) : string[] Lists all mapped repository paths.
load ( Puli\Manager\Api\Module\Module $containingModule, ModuleList $modules ) Loads the mapping.
removeConflict ( Puli\Manager\Api\Repository\PathConflict $conflict ) Removes a conflict from the mapping.
unload ( ) Unloads the mapping.

Private Methods

Méthode Description
assertFileExists ( $absolutePath, $relativePath, Puli\Manager\Api\Module\Module $containingModule )
makeAbsolute ( $relativePath, Puli\Manager\Api\Module\Module $containingModule, ModuleList $modules )
refreshState ( )

Method Details

__construct() public méthode

Creates a new path mapping.
public __construct ( string $repositoryPath, string | string[] $pathReferences )
$repositoryPath string The repository path.
$pathReferences string | string[] The path references.

addConflict() public méthode

A mapping can refer to at most one conflict per conflicting repository path. If the same conflict is added twice, the second addition is ignored. If a different conflict is added for an existing repository path, the previous conflict is removed before adding the new conflict for the repository path. The repository path of the conflict must either be the repository path of the mapping or any path within. If a conflict with a different path is added, an exception is thrown. The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
public addConflict ( Puli\Manager\Api\Repository\PathConflict $conflict )
$conflict Puli\Manager\Api\Repository\PathConflict The conflict to be added.

getConflictingMappings() public méthode

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
public getConflictingMappings ( ) : PathMapping[]
Résultat PathMapping[] The conflicting path mappings.

getConflictingModules() public méthode

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
public getConflictingModules ( ) : ModuleList
Résultat Puli\Manager\Api\Module\ModuleList The conflicting modules.

getConflicts() public méthode

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
public getConflicts ( ) : Puli\Manager\Api\Repository\PathConflict[]
Résultat Puli\Manager\Api\Repository\PathConflict[] The conflicts.

getContainingModule() public méthode

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
public getContainingModule ( ) : Puli\Manager\Api\Module\Module
Résultat Puli\Manager\Api\Module\Module The containing module or `null` if the mapping has not been loaded.

getFilesystemPaths() public méthode

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
public getFilesystemPaths ( ) : string[]
Résultat string[] The absolute filesystem paths.

getLoadErrors() public méthode

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
public getLoadErrors ( ) : Exceptio\Exception[]
Résultat Exceptio\Exception[] The errors that occurred during loading. If the returned array is empty, the mapping was loaded successfully.

getPathReferences() public méthode

The path references refer to filesystem paths. A path reference is either: * a path relative to the root directory of the containing module; * a path relative to the root directory of another module, prefixed with @vendor/module:, where "vendor/module" is the name of the referenced module.
public getPathReferences ( ) : string[]
Résultat string[] The path references.

getRepositoryPath() public méthode

Returns the repository path.
public getRepositoryPath ( ) : string
Résultat string The repository path.

getState() public méthode

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
public getState ( ) : integer
Résultat integer One of the {@link PathMappingState} constants.

isConflicting() public méthode

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
See also: PathMappingState::CONFLICT
public isConflicting ( ) : boolean
Résultat boolean Returns `true` if the state is {@link PathMappingState::CONFLICT}.

isEnabled() public méthode

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
See also: PathMappingState::ENABLED
public isEnabled ( ) : boolean
Résultat boolean Returns `true` if the state is {@link PathMappingState::ENABLED}.

isLoaded() public méthode

Returns whether the mapping is loaded.
public isLoaded ( ) : boolean
Résultat boolean Returns `true` if {@link load()} was called.

isNotFound() public méthode

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
See also: PathMappingState::NOT_FOUND
public isNotFound ( ) : boolean
Résultat boolean Returns `true` if the state is {@link PathMappingState::NOT_FOUND}.

listPathMappings() public méthode

Lists all filesystem path to repository path mappings of this mapping.
public listPathMappings ( ) : string[]
Résultat string[] An array of repository paths with their corresponding filesystem paths as keys. If the mapping has multiple filesystem paths, then repository paths may occur multiple times in the returned array.

listRepositoryPaths() public méthode

Contrary to {@link getRepositoryPath()}, this array also contains all nested repository paths that are mapped by this mapping.
public listRepositoryPaths ( ) : string[]
Résultat string[] A list of all mapped repository paths.

load() public méthode

Loads the mapping.
public load ( Puli\Manager\Api\Module\Module $containingModule, ModuleList $modules )
$containingModule Puli\Manager\Api\Module\Module The module that contains the mapping.
$modules Puli\Manager\Api\Module\ModuleList A list of modules that can be referenced using `@vendor/module:` prefixes in the path references.

removeConflict() public méthode

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
public removeConflict ( Puli\Manager\Api\Repository\PathConflict $conflict )
$conflict Puli\Manager\Api\Repository\PathConflict The conflict to remove.

unload() public méthode

This method reverses the effects of {@link load()}. Additionally, all associated conflicts are dereferenced.
public unload ( )