public static function Pool::resetStatusEntities in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x src/Entity/Pool.php \Drupal\cms_content_sync\Entity\Pool::resetStatusEntities()
- 2.0.x src/Entity/Pool.php \Drupal\cms_content_sync\Entity\Pool::resetStatusEntities()
Reset the status entities for this pool.
Parameters
string $pool_id: The pool the status entities should be reset for
2 calls to Pool::resetStatusEntities()
- CliService::reset_status_entities in src/
Cli/ CliService.php - Reset the status entities for a specific or all pool/s.
- ResetStatusEntityConfirmation::submitForm in src/
Form/ ResetStatusEntityConfirmation.php - Form submission handler.
File
- src/
Entity/ Pool.php, line 412
Class
- Pool
- Defines the "Content Sync - Pool" entity.
Namespace
Drupal\cms_content_sync\EntityCode
public static function resetStatusEntities($pool_id = '') {
// Reset the entity status.
$status_storage = \Drupal::entityTypeManager()
->getStorage('cms_content_sync_entity_status');
$connection = \Drupal::database();
// For a single pool.
if (!empty($pool_id)) {
// Save flags to status entities that they have been reset.
$connection
->query('UPDATE cms_content_sync_entity_status SET flags=flags|:flag WHERE last_export IS NOT NULL AND pool=:pool', [
':flag' => EntityStatus::FLAG_LAST_PUSH_RESET,
':pool' => $pool_id,
]);
$connection
->query('UPDATE cms_content_sync_entity_status SET flags=flags|:flag WHERE last_import IS NOT NULL AND pool=:pool', [
':flag' => EntityStatus::FLAG_LAST_PULL_RESET,
':pool' => $pool_id,
]);
// Actual reset.
$db_query = $connection
->update($status_storage
->getBaseTable());
$db_query
->fields([
'last_export' => null,
'last_import' => null,
]);
$db_query
->condition('pool', $pool_id);
$db_query
->execute();
}
else {
// Save flags to status entities that they have been reset.
$connection
->query('UPDATE cms_content_sync_entity_status SET flags=flags|:flag WHERE last_export IS NOT NULL', [
':flag' => EntityStatus::FLAG_LAST_PUSH_RESET,
]);
$connection
->query('UPDATE cms_content_sync_entity_status SET flags=flags|:flag WHERE last_import IS NOT NULL', [
':flag' => EntityStatus::FLAG_LAST_PULL_RESET,
]);
// Actual reset.
$db_query = $connection
->update($status_storage
->getBaseTable());
$db_query
->fields([
'last_export' => null,
'last_import' => null,
]);
$db_query
->execute();
}
// Invalidate cache by storage.
$status_storage
->resetCache();
// Above cache clearing doesn't work reliably. So we reset the whole entity cache.
\Drupal::service('cache.entity')
->deleteAll();
}