class ScaffoldFilePath (View source)

internal  
 

Manage the path to a file to scaffold.

Both the relative and full path to the file is maintained so that the shorter name may be used in progress and error messages, as needed. The name of the package that provided the file path is also recorded for the same reason.

ScaffoldFilePaths may be used to represent destination scaffold files, or the source files used to create them. Static factory methods named destinationPath and sourcePath, respectively, are provided to create ScaffoldFilePath objects.

Properties

protected string $type

The type of scaffold file this is,'autoload', 'dest' or 'src'.

protected string $packageName

The name of the package containing the file.

protected string $relativePath

The relative path to the file.

protected string $fullPath

The full path to the file.

Methods

__construct(string $path_type, string $package_name, string $rel_path, string $full_path)

ScaffoldFilePath constructor.

string
packageName()

Gets the name of the package this source file was pulled from.

string
relativePath()

Gets the relative path to the source file (best to use in messages).

string
fullPath()

Gets the full path to the source file.

sourcePath(string $package_name, string $package_path, string $destination, string $source)

Converts the relative source path into an absolute path.

destinationPath(string $package_name, string $destination, Interpolator $location_replacements)

Converts the relative destination path into an absolute path.

addInterpolationData(Interpolator $interpolator, string $name_prefix = '')

Adds data about the relative and full path to the provided interpolator.

getInterpolator(string $name_prefix = '')

Interpolate a string using the data from this scaffold file info.

Details

__construct(string $path_type, string $package_name, string $rel_path, string $full_path)

ScaffoldFilePath constructor.

Parameters

string $path_type

The type of scaffold file this is,'autoload', 'dest' or 'src'.

string $package_name

The name of the package containing the file.

string $rel_path

The relative path to the file.

string $full_path

The full path to the file.

string packageName()

Gets the name of the package this source file was pulled from.

Return Value

string

Name of package.

string relativePath()

Gets the relative path to the source file (best to use in messages).

Return Value

string

Relative path to file.

string fullPath()

Gets the full path to the source file.

Return Value

string

Full path to file.

static ScaffoldFilePath sourcePath(string $package_name, string $package_path, string $destination, string $source)

Converts the relative source path into an absolute path.

The path returned will be relative to the package installation location.

Parameters

string $package_name

The name of the package containing the source file. Only used for error messages.

string $package_path

The installation path of the package containing the source file.

string $destination

Destination location provided as a relative path. Only used for error messages.

string $source

Source location provided as a relative path.

Return Value

ScaffoldFilePath

Object wrapping the relative and absolute path to the source file.

static ScaffoldFilePath destinationPath(string $package_name, string $destination, Interpolator $location_replacements)

Converts the relative destination path into an absolute path.

Any placeholders in the destination path, e.g. '[web-root]', will be replaced using the provided location replacements interpolator.

Parameters

string $package_name

The name of the package defining the destination path.

string $destination

The relative path to the destination file being scaffolded.

Interpolator $location_replacements

Interpolator that includes the [web-root] and any other available placeholder replacements.

Return Value

ScaffoldFilePath

Object wrapping the relative and absolute path to the destination file.

addInterpolationData(Interpolator $interpolator, string $name_prefix = '')

Adds data about the relative and full path to the provided interpolator.

Parameters

Interpolator $interpolator

Interpolator to add data to.

string $name_prefix

(optional) Prefix to add before -rel-path and -full-path item names. Defaults to path type provided when constructing this object.

Interpolator getInterpolator(string $name_prefix = '')

Interpolate a string using the data from this scaffold file info.

Parameters

string $name_prefix

(optional) Prefix to add before -rel-path and -full-path item names. Defaults to path type provided when constructing this object.

Return Value

Interpolator

An interpolator for making string replacements.