PackagedDirectorySynchronizer
Synchronizes one packaged directory of symlinked entries into a consumer repository.
Interfaces
Properties
Methods
Initializes the synchronizer with a filesystem and finder factory.
{@inheritDoc}
Synchronizes packaged directory entries into the consumer repository.
Creates a new symlink pointing to the packaged entry.
Checks if a path is a symbolic link.
Handles an existing non-symlink item at the target path.
Evaluates an existing symlink and determines whether to preserve or repair it.
Routes an entry link to the appropriate handling method based on target state.
Removes a broken symlink and creates a fresh one pointing to the current source.
private
FilesystemInterface
$filesystem
private
FinderFactoryInterface
$finderFactory
private
LoggerInterface
$logger
Initializes the synchronizer with a filesystem and finder factory.
public
__construct(FilesystemInterface
$filesystem, FinderFactoryInterface
$finderFactory, LoggerInterface
$logger) : mixed
Parameters
Description
Filesystem instance for file operations
Description
Factory for locating packaged directories
$logger
:
LoggerInterface
Description
Logger for recording synchronization actions and decisions
{@inheritDoc}
public
setLogger(LoggerInterface
$logger) : void
Parameters
$logger
:
LoggerInterface
Synchronizes packaged directory entries into the consumer repository.
public
synchronize(
string
$targetDir,
string
$packagePath,
string
$directoryLabel) : SynchronizeResult
Parameters
$targetDir
:
string
Description
Absolute path to the consumer directory to populate
$packagePath
:
string
Description
Absolute path to the packaged directory to mirror
$directoryLabel
:
string
Description
Human-readable directory label used in log messages
Return values
Description
Result containing counts of created, preserved, and removed links
Creates a new symlink pointing to the packaged entry.
private
createNewLink(
string
$entryName,
string
$targetLink,
string
$sourcePath, SynchronizeResult
$result) : void
Parameters
$entryName
:
string
Description
Name identifying the entry
$targetLink
:
string
Description
Absolute path where the symlink will be created
$sourcePath
:
string
Description
Absolute path to the packaged directory
Description
Result object for tracking creation
Checks if a path is a symbolic link.
private
isSymlink(
string
$path) : bool
Parameters
$path
:
string
Description
the target path
Return values
Description
whether the path is a symbolic link
Handles an existing non-symlink item at the target path.
private
preserveExistingNonSymlink(
string
$entryName, SynchronizeResult
$result) : void
Parameters
$entryName
:
string
Description
Name of the entry with the conflicting item
Description
Result tracker for preserved items
Evaluates an existing symlink and determines whether to preserve or repair it.
private
processExistingSymlink(
string
$entryName,
string
$targetLink,
string
$sourcePath, SynchronizeResult
$result) : void
Parameters
$entryName
:
string
Description
Name of the entry with the existing symlink
$targetLink
:
string
Description
Absolute path to the existing symlink
$sourcePath
:
string
Description
Absolute path to the expected source directory
Description
Result tracker for preserved or removed links
Routes an entry link to the appropriate handling method based on target state.
private
processLink(
string
$entryName,
string
$targetLink,
string
$sourcePath, SynchronizeResult
$result) : void
Parameters
$entryName
:
string
Description
Name of the packaged entry being processed
$targetLink
:
string
Description
Absolute path where the symlink should exist
$sourcePath
:
string
Description
Absolute path to the packaged source directory
Description
Result tracker for reporting outcomes
Removes a broken symlink and creates a fresh one pointing to the current source.
private
repairBrokenLink(
string
$entryName,
string
$targetLink,
string
$sourcePath, SynchronizeResult
$result) : void
Parameters
$entryName
:
string
Description
Name of the entry with the broken symlink
$targetLink
:
string
Description
Absolute path to the broken symlink
$sourcePath
:
string
Description
Absolute path to the current packaged directory
Description
Result tracker for removed and created items