class LegacyAliasConverter (View source)

Find all legacy alias files and convert them to an equivalent '.yml' file.

We will check the respective mod date of the legacy file and the generated file, and update the generated file when the legacy file changes.

Properties

protected SiteAliasFileDiscovery $discovery
protected string $target
protected boolean $converted
protected boolean $simulate
protected array $convertedFileMap

Methods

__construct(SiteAliasFileDiscovery $discovery)

LegacyAliasConverter constructor.

bool
isSimulate()

No description

setSimulate(bool $simulate)

No description

setTargetDir(string $target)

No description

convertOnce()

No description

convert()

No description

checkAnyNeedsConversion($legacyFiles)

No description

convertAll($legacyFiles)

No description

writeAll($convertedFiles)

No description

getContents($path, $data)

No description

writeOne($path, $contents)

No description

safeToWrite($path, $contents, $checksumPath)

Without any safeguards, the conversion process could be very dangerous to users who modify their converted alias files (as we would encourage them to do, if the goal is to convert!).

saveChecksum($checksumPath, $path, $contents)

No description

readChecksum($checksumPath)

No description

checksumPath($path)

No description

calculateChecksum($data)

No description

determineConvertedFilename($legacyFile)

No description

cacheConvertedFilePath($legacyFile, $convertedFile)

No description

recoverLegacyFile($convertedFile)

No description

checkNeedsConversion($legacyFile, $convertedFile)

No description

convertLegacyFile($legacyFile)

No description

convertSingleAliasLegacyFile($legacyFile, $options)

No description

convertMultipleAliasesLegacyFile($legacyFile, $aliases, $options)

No description

convertAlias($aliasName, $data, $dir = '')

No description

fixSiteData($data)

No description

remapData($data)

No description

keyConversion()

Anything in the key of the returned array is converted and written to a new top-level item in the result.

dataRemap()

This table allows for flexible remapping from one location in the original alias to any other location in the target alias.

removePercentFromKey($data)

No description

convertSingleFileAlias($aliasName, $env, $data, $dir = '')

No description

outputFilename($name, $extension, $dir = '')

No description

static array
arrayMergeRecursiveDistinct(array $array1, array $array2)

Merges arrays recursively while preserving.

Details

__construct(SiteAliasFileDiscovery $discovery)

LegacyAliasConverter constructor.

Parameters

SiteAliasFileDiscovery $discovery Provide the same discovery object as used by the SiteAliasFileLoader to ensure that the same search locations are used for both classed.

bool isSimulate()

Return Value

bool

setSimulate(bool $simulate)

Parameters

bool $simulate

setTargetDir(string $target)

Parameters

string $target A directory to write to. If not provided, writes go into same dir as the corresponding legacy file.

convertOnce()

convert()

protected checkAnyNeedsConversion($legacyFiles)

Parameters

$legacyFiles

protected convertAll($legacyFiles)

Parameters

$legacyFiles

protected writeAll($convertedFiles)

Parameters

$convertedFiles

protected getContents($path, $data)

Parameters

$path
$data

protected writeOne($path, $contents)

Parameters

$path
$contents

protected safeToWrite($path, $contents, $checksumPath)

Without any safeguards, the conversion process could be very dangerous to users who modify their converted alias files (as we would encourage them to do, if the goal is to convert!).

This method determines whether it is safe to write to the converted alias file at the specified path. If the user has modified the target file, then we will not overwrite it.

Parameters

$path
$contents
$checksumPath

saveChecksum($checksumPath, $path, $contents)

Parameters

$checksumPath
$path
$contents

protected readChecksum($checksumPath)

Parameters

$checksumPath

protected checksumPath($path)

Parameters

$path

protected calculateChecksum($data)

Parameters

$data

protected determineConvertedFilename($legacyFile)

Parameters

$legacyFile

protected cacheConvertedFilePath($legacyFile, $convertedFile)

Parameters

$legacyFile
$convertedFile

protected recoverLegacyFile($convertedFile)

Parameters

$convertedFile

protected checkNeedsConversion($legacyFile, $convertedFile)

Parameters

$legacyFile
$convertedFile

protected convertLegacyFile($legacyFile)

Parameters

$legacyFile

protected convertSingleAliasLegacyFile($legacyFile, $options)

Parameters

$legacyFile
$options

protected convertMultipleAliasesLegacyFile($legacyFile, $aliases, $options)

Parameters

$legacyFile
$aliases
$options

protected convertAlias($aliasName, $data, $dir = '')

Parameters

$aliasName
$data
$dir

protected fixSiteData($data)

Parameters

$data

protected remapData($data)

Parameters

$data

protected keyConversion()

Anything in the key of the returned array is converted and written to a new top-level item in the result.

Anything NOT identified by the key in the returned array is moved to the 'options' element.

protected dataRemap()

This table allows for flexible remapping from one location in the original alias to any other location in the target alias.

n.b. Most arbitrary data from the original alias will have been moved into the 'options' element before this remapping table is consulted.

protected removePercentFromKey($data)

Parameters

$data

protected convertSingleFileAlias($aliasName, $env, $data, $dir = '')

Parameters

$aliasName
$env
$data
$dir

protected outputFilename($name, $extension, $dir = '')

Parameters

$name
$extension
$dir

static protected array arrayMergeRecursiveDistinct(array $array1, array $array2)

Merges arrays recursively while preserving.