PackagedDirectorySynchronizer

Class
implements LoggerAwareInterface
Final: Yes

Synchronizes one packaged directory of symlinked entries into a consumer repository.

Table of Contents

Interfaces

Properties

Methods

__construct()

Initializes the synchronizer with a filesystem and finder factory.

 : mixed
setLogger()

{@inheritDoc}

 : void
synchronize()

Synchronizes packaged directory entries into the consumer repository.

 : SynchronizeResult
createNewLink()

Creates a new symlink pointing to the packaged entry.

 : void
isSymlink()

Checks if a path is a symbolic link.

 : bool
preserveExistingNonSymlink()

Handles an existing non-symlink item at the target path.

 : void
processExistingSymlink()

Evaluates an existing symlink and determines whether to preserve or repair it.

 : void
processLink()

Routes an entry link to the appropriate handling method based on target state.

 : void
repairBrokenLink()

Removes a broken symlink and creates a fresh one pointing to the current source.

 : void
Properties
Methods

__construct()

Public

Initializes the synchronizer with a filesystem and finder factory.

public __construct(FilesystemInterface  $filesystem, FinderFactoryInterface  $finderFactory, LoggerInterface  $logger) : mixed
Parameters
$filesystem : FilesystemInterface

Description

Filesystem instance for file operations

$finderFactory : FinderFactoryInterface

Description

Factory for locating packaged directories

$logger : LoggerInterface

Description

Logger for recording synchronization actions and decisions

setLogger()

Public

{@inheritDoc}

public setLogger(LoggerInterface  $logger) : void
Parameters
$logger : LoggerInterface

synchronize()

Public

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

Private

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

$result : SynchronizeResult

Description

Result object for tracking creation

Private

Checks if a path is a symbolic link.

private isSymlink( string  $path) : bool
Parameters
$path : string

Description

the target path

Return values
bool

Description

whether the path is a symbolic link

Private

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

$result : SynchronizeResult

Description

Result tracker for preserved items

Private

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

$result : SynchronizeResult

Description

Result tracker for preserved or removed links

Private

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

$result : SynchronizeResult

Description

Result tracker for reporting outcomes

Private

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

$result : SynchronizeResult

Description

Result tracker for removed and created items