function hook_entity_info() {
$return = array(
'node_type' => array(
'label' => t('Node type'),
'base table' => 'node_type',
'operations' => array(
'delete' => array(
'node' => 'delete',
),
),
),
),
}
This piece of code basically means entity API will automatically delete nodes related to a node type that is being deleted. It allows you to specify which operation needs to be performed on related entities if a certain operation is being applied to the defined entity. Valid operations are "load" and "update"/"delete" (currently not yet supported by the API).
Use cases:
- No more ghost nodes after a node type has been deleted.
- Nodes will be updated after the text format they use has been changed.
This idea came forward after a discussion between webchick, beeradb and me. Fago explained that this can also be done using hooks, which is true, but this extension to hook_entity_info() means less code in the end. Although this might not be a good enough argument to actually implement it, I do want to explore the possibilities such a new feature may offer us.
Comments
Comment #1
ctmattice1 CreditAttribution: ctmattice1 commentedThis would probably have to be the last part of the deletion process though, the comment module is looking for the type as well.
Either that or $info->type will have to be set in some variable before it's run so other entities will have it available for their part in the process.
Comment #2
rfayNot AJAX. "Base system"?
Comment #3
XanoWe now have entity list controllers.