FileIndexRepository
readonly class \
Repository Class as an abstraction layer to sys_file
Every access to table sys_file_metadata which is not handled by DataHandler has to use this Repository class.
Internal
This is meant for FAL internal use only!
Attributes
- #[Autoconfigure]
- $public: true
Table of Contents
Constants
- FIELDS : mixed = ['uid', 'pid', 'missing', 'type', 'storage', 'i...
- A list of properties which are to be persisted
Methods
- __construct() : mixed
- add() : void
- Adds a file to the index
- addRaw() : array
- Add data from record (at indexing time)
- findByContentHash() : array
- Returns all indexed files which match the content hash Used by the indexer to detect already present files
- findByFolder() : array
- Find all records for files in a Folder
- findByFolders() : array
- Find all records for files in an array of Folders
- findInStorageAndNotInUidList() : array
- Helper function for the Indexer to detect missing files
- findInStorageWithIndexOutstanding() : array
- Finds the files needed for second indexer step
- findOneByFileObject() : array|false
- Retrieves Index record for a given $fileObject
- findOneByStorageAndIdentifier() : array|false
- Retrieves Index record for a given $storageUid and $identifier
- findOneByStorageUidAndIdentifierHash() : array|false
- Retrieves Index record for a given $storageUid and $identifier
- findOneByUid() : array|false
- Retrieves Index record for a given $fileUid
- hasIndexRecord() : bool
- Checks if a file is indexed
- iterateUidsAndIdentifiersInStorage() : Generator<string|int, array{uid: int, identifier: string}>
- Helper function for the Indexer to detect missing files without holding all records of a storage in memory
- markFileAsMissing() : void
- Marks given file as missing in sys_file
- remove() : void
- Remove a sys_file record from the database
- update() : void
- Updates the index record in the database
- updateIndexingTime() : void
- Updates the timestamp when the file indexer extracted metadata
- insertRecord() : int
- Helper to reduce code duplication
- updateRefIndex() : void
- Update Reference Index (sys_refindex) for a file
Constants
FIELDS
A list of properties which are to be persisted
protected
mixed
FIELDS
= ['uid', 'pid', 'missing', 'type', 'storage', 'identifier', '…Show the full value
['uid', 'pid', 'missing', 'type', 'storage', 'identifier', 'identifier_hash', 'extension', 'mime_type', 'name', 'sha1', 'size', 'creation_date', 'modification_date', 'folder_hash']
Methods
__construct()
public
__construct(EventDispatcherInterface $eventDispatcher, ConnectionPool $connectionPool) : mixed
Parameters
- $eventDispatcher : EventDispatcherInterface
- $connectionPool : ConnectionPool
add()
Adds a file to the index
public
add(File $file) : void
Parameters
- $file : File
addRaw()
Add data from record (at indexing time)
public
addRaw(array $data) : array
Parameters
- $data : array
Return values
arrayfindByContentHash()
Returns all indexed files which match the content hash Used by the indexer to detect already present files
public
findByContentHash(string $hash) : array
Parameters
- $hash : string
Return values
arrayfindByFolder()
Find all records for files in a Folder
public
findByFolder(Folder $folder) : array
Parameters
- $folder : Folder
Return values
arrayfindByFolders()
Find all records for files in an array of Folders
public
findByFolders(Folder[] $folders[, bool $includeMissing = true ][, string|null $fileName = null ]) : array
Parameters
- $folders : Folder[]
- $includeMissing : bool = true
- $fileName : string|null = null
Return values
arrayfindInStorageAndNotInUidList()
Helper function for the Indexer to detect missing files
public
findInStorageAndNotInUidList(ResourceStorage $storage, int[] $uidList) : array
Parameters
- $storage : ResourceStorage
- $uidList : int[]
Return values
arrayfindInStorageWithIndexOutstanding()
Finds the files needed for second indexer step
public
findInStorageWithIndexOutstanding(ResourceStorage $storage[, int $limit = -1 ]) : array
Parameters
- $storage : ResourceStorage
- $limit : int = -1
Return values
arrayfindOneByFileObject()
Retrieves Index record for a given $fileObject
public
findOneByFileObject(FileInterface $fileObject) : array|false
Parameters
- $fileObject : FileInterface
Internal
only for use from FileRepository
Return values
array|falsefindOneByStorageAndIdentifier()
Retrieves Index record for a given $storageUid and $identifier
public
findOneByStorageAndIdentifier(ResourceStorage $storage, string $identifier) : array|false
Parameters
- $storage : ResourceStorage
- $identifier : string
Internal
only for use from FileRepository
Return values
array|falsefindOneByStorageUidAndIdentifierHash()
Retrieves Index record for a given $storageUid and $identifier
public
findOneByStorageUidAndIdentifierHash(int $storageUid, string $identifierHash) : array|false
Parameters
- $storageUid : int
- $identifierHash : string
Internal
only for use from FileRepository
Return values
array|falsefindOneByUid()
Retrieves Index record for a given $fileUid
public
findOneByUid(int $fileUid) : array|false
Parameters
- $fileUid : int
Return values
array|falsehasIndexRecord()
Checks if a file is indexed
public
hasIndexRecord(File $file) : bool
Parameters
- $file : File
Return values
booliterateUidsAndIdentifiersInStorage()
Helper function for the Indexer to detect missing files without holding all records of a storage in memory
public
iterateUidsAndIdentifiersInStorage(ResourceStorage $storage) : Generator<string|int, array{uid: int, identifier: string}>
Parameters
- $storage : ResourceStorage
Return values
Generator<string|int, array{uid: int, identifier: string}>markFileAsMissing()
Marks given file as missing in sys_file
public
markFileAsMissing(int $fileUid) : void
Parameters
- $fileUid : int
remove()
Remove a sys_file record from the database
public
remove(int $fileUid) : void
Parameters
- $fileUid : int
update()
Updates the index record in the database
public
update(File $file) : void
Parameters
- $file : File
updateIndexingTime()
Updates the timestamp when the file indexer extracted metadata
public
updateIndexingTime(int $fileUid) : void
Parameters
- $fileUid : int
insertRecord()
Helper to reduce code duplication
protected
insertRecord(array $data) : int
Parameters
- $data : array
Return values
intupdateRefIndex()
Update Reference Index (sys_refindex) for a file
protected
updateRefIndex(int $id) : void
Parameters
- $id : int