HostPath
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
HostPath constructor
Return the alias record portion of the host path.
Returns true if this host path points at a remote machine
Return just the path portion, without considering the alias root.
Return the original host path string, as provided to the create() method.
Return just the path portion of the host path
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 just the path alias portion of the path (e.g. '%files'), or empty if there is no alias in the path.
Replaces the path alias portion of the path with the resolved path.
Return the host portion of the host path, including the user.
Return the fully resolved path, e.g. user@server:/path/to/drupalroot/sites/default/files
Our fully qualified path passes the result through Path::makeAbsolute() which canonicallizes the path, removing any trailing slashes.
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
static
create(SiteAliasManager $manager, string $hostPath)
Factory method to create a host path.
SiteAlias
getSiteAlias()
Return the alias record portion of the host path.
getAliasRecord()
deprecated
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.
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.
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.