function scald_atom_delete_multiple in Scald: Media Management made easy 7
Delete multiple Scald atoms.
@codingStandardsIgnoreStart
Parameters
array $sids: An array of Scald atom IDs.
1 call to scald_atom_delete_multiple()
- scald_atom_delete in ./
scald.module - Delete a Scald atom.
File
- ./
scald.module, line 522 - The Scald Core, which handles all Scald Registries and dispatch.
Code
function scald_atom_delete_multiple($sids) {
// @codingStandardsIgnoreEnd
$atoms = scald_atom_load_multiple($sids);
if ($atoms) {
$transaction = db_transaction();
try {
// Unregister the atom.
$atoms = scald_atom_load_multiple($sids);
foreach ($atoms as $atom) {
// First, unregister the atom, which will mark it as unavailable.
scald_unregister_atom($atom);
// Notify all modules that the atom is going to be fully deleted.
module_invoke_all('scald_atom_delete', $atom);
module_invoke_all('entity_delete', $atom, 'scald_atom');
// Then invoke Field delete handlers.
field_attach_delete('scald_atom', $atom);
}
// Finally, delete the Scald atoms.
db_delete('scald_atoms')
->condition('sid', array_keys($atoms), 'IN')
->execute();
} catch (Exception $e) {
$transaction
->rollback();
watchdog_exception('scald_atom', $e);
throw $e;
}
}
// And end up clearing up our static load cache.
entity_get_controller('scald_atom')
->resetCache();
}