Drupal 7 and module_invoke_all
Take a look at the delete
method in the Artwork controller class over at GitHub (code samples from Drupal book Drupal 7 Module Development
.
In particular, take note of line 166:
module_invoke_all('entity_delete', $artwork, 'artwork');
In this case, $artwork is an out-of-scope variable. Am I correct in assuming that this should have been the following instead:
module_invoke_all('e开发者_如何转开发ntity_delete', $artworks, 'artwork');
If that is the case, would this invoke once for each entity in the $artworks array or just once overall?
Nice find. To me though, it seems like line 166 belongs in the foreach loop on 152.
foreach ($artworks as $artwork_id => $artwork) {
hook_entity_delete handles a single entity and other parts of that ActivityController class handle a single artwork, not an array of artwork objects.
I'll feel more comfy going with a disclaimer that this is just what I'm concluding after a little bit of looking. Don't have enough time to be 100%. Just putting it out there.
精彩评论