function scald_unregister_atom in Scald: Media Management made easy 7
Same name and namespace in other branches
- 6 scald.module \scald_unregister_atom()
Unregister a Scald Atom.
Parameters
mixed $sid: The Scald ID of the Atom being unregistered *OR* the Atom object.
Return value
bool TRUE is the atom was successfully unregistered, FALSE otherwise
1 call to scald_unregister_atom()
- scald_atom_delete_multiple in ./
scald.module - Delete multiple Scald atoms.
File
- ./
scald.module, line 564 - The Scald Core, which handles all Scald Registries and dispatch.
Code
function scald_unregister_atom($sid) {
if (is_object($sid)) {
$sid = $sid->sid;
}
// If we couldn't get back to the atom id at this point, we won't be able to
// unregister the atom, so let's just abort.
if (!is_numeric($sid)) {
return FALSE;
}
// Force a rebuild to ensure that the most-current instance is being used as
// when informing Providers of the impending destruction.
$atom = scald_fetch($sid, TRUE);
// If we couldn't fetch the object, abort early too, the atom has already been
// unregistered.
if (!is_object($atom)) {
return FALSE;
}
$types = scald_types();
$transcoders = scald_transcoders();
// Revoke all permissions on the Atom, making it inaccessible.
db_update('scald_atoms')
->fields(array(
'actions' => 0,
))
->condition('sid', $sid)
->execute();
// Alert the Providers that this Atom is gone.
module_invoke($types[$atom->type]->provider, 'scald_unregister_atom', $atom, 'type');
module_invoke($atom->provider, 'scald_unregister_atom', $atom, 'atom');
foreach (scald_contexts() as $context => $details) {
if (isset($details['type_format'][$atom->type]) && ($transcoder = $details['type_format'][$atom->type]['transcoder'])) {
module_invoke($transcoders[$transcoder]['provider'], 'scald_unregister_atom', $atom, 'transcoder');
}
}
// Clear the memory cache.
scald_is_registered($sid, TRUE);
// Clear the render cache.
cache_clear_all($sid . ':', 'cache_scald', TRUE);
}