protected function ContentIndexerTrait::acquireContentIndexLock in Tome 8
Acquires a lock for writing to the index.
Return value
resource A file pointer resource on success.
Throws
\Exception Throws an exception when the index file cannot be written to.
2 calls to ContentIndexerTrait::acquireContentIndexLock()
- ContentIndexerTrait::indexContent in modules/
tome_sync/ src/ ContentIndexerTrait.php - Writes content to the index.
- ContentIndexerTrait::unIndexContentByName in modules/
tome_sync/ src/ ContentIndexerTrait.php - Removes content from the index.
File
- modules/
tome_sync/ src/ ContentIndexerTrait.php, line 134
Class
- ContentIndexerTrait
- Provides methods for reading and writing the index file.
Namespace
Drupal\tome_syncCode
protected function acquireContentIndexLock() {
$destination = $this
->getContentIndexFilePath();
$directory = dirname($destination);
$this->fileSystem
->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY);
$handle = fopen($destination, 'c+');
if (!flock($handle, LOCK_EX)) {
throw new \Exception('Unable to acquire lock for the index file.');
}
return $handle;
}