Commit fee217fa authored by Dries's avatar Dries

- Patch #970258 by Dave Reid: example documentation for...

- Patch #970258 by Dave Reid: example documentation for hook_entity_insert()/update/delete() will cause PHP strict errors.
parent a160006d
...@@ -286,7 +286,7 @@ function hook_entity_load($entities, $type) { ...@@ -286,7 +286,7 @@ function hook_entity_load($entities, $type) {
function hook_entity_insert($entity, $type) { function hook_entity_insert($entity, $type) {
// Insert the new entity into a fictional table of all entities. // Insert the new entity into a fictional table of all entities.
$info = entity_get_info($type); $info = entity_get_info($type);
$id = reset(entity_extract_ids($type, $entity)); list($id) = entity_extract_ids($type, $entity);
db_insert('example_entity') db_insert('example_entity')
->fields(array( ->fields(array(
'type' => $type, 'type' => $type,
...@@ -308,7 +308,7 @@ function hook_entity_insert($entity, $type) { ...@@ -308,7 +308,7 @@ function hook_entity_insert($entity, $type) {
function hook_entity_update($entity, $type) { function hook_entity_update($entity, $type) {
// Update the entity's entry in a fictional table of all entities. // Update the entity's entry in a fictional table of all entities.
$info = entity_get_info($type); $info = entity_get_info($type);
$id = reset(entity_extract_ids($type, $entity)); list($id) = entity_extract_ids($type, $entity);
db_update('example_entity') db_update('example_entity')
->fields(array( ->fields(array(
'updated' => REQUEST_TIME, 'updated' => REQUEST_TIME,
...@@ -329,7 +329,7 @@ function hook_entity_update($entity, $type) { ...@@ -329,7 +329,7 @@ function hook_entity_update($entity, $type) {
function hook_entity_delete($entity, $type) { function hook_entity_delete($entity, $type) {
// Delete the entity's entry from a fictional table of all entities. // Delete the entity's entry from a fictional table of all entities.
$info = entity_get_info($type); $info = entity_get_info($type);
$id = reset(entity_extract_ids($type, $entity)); list($id) = entity_extract_ids($type, $entity);
db_delete('example_entity') db_delete('example_entity')
->condition('type', $type) ->condition('type', $type)
->condition('id', $id) ->condition('id', $id)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment