protected function ContentIndexerTrait::unIndexContentByName in Tome 8
Removes content from the index.
Parameters
string $name: A content name.
2 calls to ContentIndexerTrait::unIndexContentByName()
- CleanFilesCommand::execute in modules/
tome_sync/ src/ Commands/ CleanFilesCommand.php - ContentIndexerTrait::unIndexContent in modules/
tome_sync/ src/ ContentIndexerTrait.php - Removes content from the index.
File
- modules/
tome_sync/ src/ ContentIndexerTrait.php, line 105
Class
- ContentIndexerTrait
- Provides methods for reading and writing the index file.
Namespace
Drupal\tome_syncCode
protected function unIndexContentByName($name) {
$handle = $this
->acquireContentIndexLock();
$contents = stream_get_contents($handle);
if (empty($contents)) {
return;
}
$index = json_decode($contents, TRUE);
if (isset($index[$name])) {
unset($index[$name]);
}
foreach ($index as &$dependencies) {
$dependencies = array_diff($dependencies, [
$name,
]);
}
ftruncate($handle, 0);
rewind($handle);
fwrite($handle, json_encode($index, JSON_PRETTY_PRINT));
flock($handle, LOCK_UN);
}