Closed (fixed)
Project:
Examples for Developers
Version:
7.x-1.x-dev
Component:
Entity Example
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Oct 2012 at 15:11 UTC
Updated:
8 Nov 2012 at 07:01 UTC
In
public function save($entity)
We have two module_invoke_all functions to
hook_entity_presave()
hook_entity_update() or hook_entity_insert()
// Invoke hook_entity_presave().
module_invoke_all('entity_presave', 'entity_example_basic', $entity);
$invocation = 'entity_insert';
// Now we need to either insert or update the fields which are
// attached to this entity. We use the same primary_keys logic
// to determine whether to update or insert, and which hook we
// need to invoke.
if (empty($primary_keys)) {
field_attach_insert('entity_example_basic', $entity);
}
else {
field_attach_update('entity_example_basic', $entity);
$invocation = 'entity_update';
}
// Invoke either hook_entity_update() or hook_entity_insert().
module_invoke_all($invocation, 'entity_example_basic', $entity);
We send the arguments: $hook, $entity_type, $entity.
And the correct arguments are: $hook, $entity, $entity_type
@link: hook_entity_presave
Regards!
| Comment | File | Size | Author |
|---|---|---|---|
| fix_module_invoke_all_arguments.patch | 1004 bytes | facine |
Comments
Comment #1
mile23Thanks, facine. Let's see what the test bot says.
Comment #2
mile23And... committed. Thanks, facine. :-)
http://drupalcode.org/project/examples.git/commitdiff/e67ca6be70a438d7b4...
Comment #3
facine commentedThanks you.
Regards!
Comment #4
SlashCrew commentedThis has course much headache here. Just found the bug, and wanted to report it, but you beat me to it. :-)
Comment #5.0
(not verified) commentedAdd link