FileMonitor
class FileMonitor (View source)
A monitor which detects changes in directories or files
Properties
protected string | $identifier | ||
protected ChangeDetectionStrategyInterface | $changeDetectionStrategy | ||
protected Dispatcher | $signalDispatcher | ||
protected LoggerInterface | $logger | ||
protected StringFrontend | $cache | ||
protected array | $monitoredFiles | ||
protected array | $monitoredDirectories | ||
protected array | $changedFiles | Changed files for this monitor |
|
protected array | $changedPaths | The changed paths for this monitor |
|
protected array|null | $directoriesAndFiles | Array of directories and files that were cached on the last run. |
Methods
Constructs this file monitor
Helper method to create a FileMonitor instance during boot sequence as injections have to be done manually.
Injects the Change Detection Strategy
Injects the Singal Slot Dispatcher because classes of the Monitor subpackage cannot be proxied by the AOP framework because it is not initialized at the time the monitoring is used.
Injects the (system) logger based on PSR-3.
Returns the identifier of this monitor
Adds the specified file to the list of files to be monitored.
Adds the specified directory to the list of directories to be monitored.
Returns a list of all monitored files
Returns a list of all monitored directories
Detects changes of the files and directories to be monitored and emits signals accordingly.
Detect changes for one of the monitored paths.
Read a monitored directory recursively, taking into account filename patterns
Loads the last detected files for this monitor.
Store the changed directories and files back to the cache.
No description
Detects changes in the given list of files and emits signals if necessary.
Signalizes that the specified file has changed
Signalizes that the specified directory has changed
Caches the directories and their files
Details
__construct(string $identifier)
Constructs this file monitor
static FileMonitor
createFileMonitorAtBoot(string $identifier, Bootstrap $bootstrap)
Helper method to create a FileMonitor instance during boot sequence as injections have to be done manually.
void
injectChangeDetectionStrategy(ChangeDetectionStrategyInterface $changeDetectionStrategy)
Injects the Change Detection Strategy
void
injectSignalDispatcher(Dispatcher $signalDispatcher)
Injects the Singal Slot Dispatcher because classes of the Monitor subpackage cannot be proxied by the AOP framework because it is not initialized at the time the monitoring is used.
void
injectLogger(LoggerInterface $logger)
Injects the (system) logger based on PSR-3.
void
injectCache(StringFrontend $cache)
Injects the Flow_Monitor cache
string
getIdentifier()
Returns the identifier of this monitor
void
monitorFile(string $pathAndFilename)
Adds the specified file to the list of files to be monitored.
The file in question does not necessarily have to exist.
void
monitorDirectory(string $path, string $filenamePattern = null)
Adds the specified directory to the list of directories to be monitored.
All files in these directories will be monitored too.
array
getMonitoredFiles()
Returns a list of all monitored files
array
getMonitoredDirectories()
Returns a list of all monitored directories
void
detectChanges()
Detects changes of the files and directories to be monitored and emits signals accordingly.
protected bool
detectChangesOnPath(string $path, string $filenamePattern)
Detect changes for one of the monitored paths.
protected Generator<string>
readMonitoredDirectoryRecursively(string $path, string $filenamePattern)
Read a monitored directory recursively, taking into account filename patterns
protected void
loadDetectedDirectoriesAndFiles()
Loads the last detected files for this monitor.
protected void
saveDetectedDirectoriesAndFiles()
Store the changed directories and files back to the cache.
protected void
setDetectedFilesForPath(string $path, array $files)
No description
protected array
detectChangedFiles(array $pathAndFilenames)
Detects changes in the given list of files and emits signals if necessary.
protected void
emitFilesHaveChanged(string $monitorIdentifier, array $changedFiles)
Signalizes that the specified file has changed
protected void
emitDirectoriesHaveChanged(string $monitorIdentifier, array $changedDirectories)
Signalizes that the specified directory has changed
void
shutdownObject()
Caches the directories and their files