class HostPath (View source)

A host path is a path on some machine. The machine may be specified by a label, and the label may be an @alias or a site specification.

If there is no label, then the local machine is assumed.

Examples:

Properties

protected SiteAlias $alias_record
protected string $original_path
protected string $path
protected string $implicit

Methods

__construct(SiteAlias $alias_record, string $original_path, string $path = '', $implicit = false)

HostPath constructor

static 
create(SiteAliasManager $manager, string $hostPath)

Factory method to create a host path.

getSiteAlias()

Return the alias record portion of the host path.

getAliasRecord() deprecated

No description

bool
isRemote()

Returns true if this host path points at a remote machine

string
getOriginalPath()

Return just the path portion, without considering the alias root.

string
getOriginal()

Return the original host path string, as provided to the create() method.

string
getPath()

Return just the path portion of the host path

bool
hasPathAlias()

Returns 'true' if the path portion of the host path begins with a path alias (e.g. '%files'). Path aliases must appear at the beginning of the path.

string
getPathAlias()

Return just the path alias portion of the path (e.g. '%files'), or empty if there is no alias in the path.

$this
replacePathAlias(string $resolvedPath)

Replaces the path alias portion of the path with the resolved path.

string
getHost()

Return the host portion of the host path, including the user.

string
fullyQualifiedPath()

Return the fully resolved path, e.g. user@server:/path/to/drupalroot/sites/default/files

string
fullyQualifiedPathPreservingTrailingSlash()

Our fully qualified path passes the result through Path::makeAbsolute() which canonicallizes the path, removing any trailing slashes.

static 
determinePathOrAlias(SiteAliasManager $manager, SiteAlias|bool $alias_record, string $hostPath, string $single_part)

Helper method for HostPath::create(). When the host path contains no ':', this method determines whether the string that was provided is a host or a path.

Details

protected __construct(SiteAlias $alias_record, string $original_path, string $path = '', $implicit = false)

HostPath constructor

Parameters

SiteAlias $alias_record

The alias record or site specification record

string $original_path

The original host path

string $path

Just the 'path' component

$implicit

static create(SiteAliasManager $manager, string $hostPath)

Factory method to create a host path.

Parameters

SiteAliasManager $manager

We need to be provided a reference to the alias manager to create a host path

string $hostPath

The path to create.

SiteAlias getSiteAlias()

Return the alias record portion of the host path.

Return Value

SiteAlias

getAliasRecord() deprecated

deprecated Use getSiteAlias

No description

bool isRemote()

Returns true if this host path points at a remote machine

Return Value

bool

string getOriginalPath()

Return just the path portion, without considering the alias root.

Return Value

string

string getOriginal()

Return the original host path string, as provided to the create() method.

Return Value

string

string getPath()

Return just the path portion of the host path

Return Value

string

bool hasPathAlias()

Returns 'true' if the path portion of the host path begins with a path alias (e.g. '%files'). Path aliases must appear at the beginning of the path.

Return Value

bool

string getPathAlias()

Return just the path alias portion of the path (e.g. '%files'), or empty if there is no alias in the path.

Return Value

string

$this replacePathAlias(string $resolvedPath)

Replaces the path alias portion of the path with the resolved path.

Parameters

string $resolvedPath

The converted path alias (e.g. 'sites/default/files')

Return Value

$this

string getHost()

Return the host portion of the host path, including the user.

Return Value

string

string fullyQualifiedPath()

Return the fully resolved path, e.g. user@server:/path/to/drupalroot/sites/default/files

Return Value

string

string fullyQualifiedPathPreservingTrailingSlash()

Our fully qualified path passes the result through Path::makeAbsolute() which canonicallizes the path, removing any trailing slashes.

That is what we want most of the time; however, the trailing slash is sometimes significant, e.g. for rsync, so we provide a separate API for those cases where the trailing slash should be preserved.

Return Value

string

static protected determinePathOrAlias(SiteAliasManager $manager, SiteAlias|bool $alias_record, string $hostPath, string $single_part)

Helper method for HostPath::create(). When the host path contains no ':', this method determines whether the string that was provided is a host or a path.

Parameters

SiteAliasManager $manager
SiteAlias|bool $alias_record
string $hostPath
string $single_part