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])
Exibir arquivo Open project: puli/manager Class Usage Examples

Public Methods

Method 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

Method 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 method

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 method

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 method

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

getConflictingModules() public method

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

getConflicts() public method

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

getContainingModule() public method

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

getFilesystemPaths() public method

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

getLoadErrors() public method

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

getPathReferences() public method

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[]
return string[] The path references.

getRepositoryPath() public method

Returns the repository path.
public getRepositoryPath ( ) : string
return string The repository path.

getState() public method

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

isConflicting() public method

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

isEnabled() public method

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

isLoaded() public method

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

isNotFound() public method

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
return boolean Returns `true` if the state is {@link PathMappingState::NOT_FOUND}.

listPathMappings() public method

Lists all filesystem path to repository path mappings of this mapping.
public listPathMappings ( ) : string[]
return 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 method

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

load() public method

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 method

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 method

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