Révision b858700c
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/commerce/includes/commerce.controller.inc | ||
---|---|---|
94 | 94 |
$function($this->entityType, $entity); |
95 | 95 |
} |
96 | 96 |
|
97 |
// Invoke the hook. If rules is there, use the rule funtion so that a rules |
|
98 |
// event is invoked too. |
|
99 |
if (module_exists('rules')) { |
|
100 |
rules_invoke_all($this->entityType . '_' . $hook, $entity); |
|
101 |
} |
|
102 |
else { |
|
103 |
module_invoke_all($this->entityType . '_' . $hook, $entity); |
|
104 |
} |
|
97 |
// Invoke the hook. |
|
98 |
module_invoke_all($this->entityType . '_' . $hook, $entity); |
|
105 | 99 |
// Invoke the respective entity level hook. |
106 | 100 |
if ($hook == 'presave' || $hook == 'insert' || $hook == 'update' || $hook == 'delete') { |
107 | 101 |
module_invoke_all('entity_' . $hook, $entity, $this->entityType); |
108 | 102 |
} |
103 |
// Invoke rules. |
|
104 |
if (module_exists('rules')) { |
|
105 |
rules_invoke_event($this->entityType . '_' . $hook, $entity); |
|
106 |
} |
|
109 | 107 |
} |
110 | 108 |
|
111 | 109 |
/** |
... | ... | |
181 | 179 |
} |
182 | 180 |
|
183 | 181 |
try { |
184 |
// Load the stored entity, if any. |
|
185 |
if (!empty($entity->{$this->idKey}) && !isset($entity->original)) { |
|
182 |
// Load the stored entity, if any. If this save was invoked during a |
|
183 |
// previous save's insert or update hook, this means the $entity->original |
|
184 |
// value already set on the entity will be replaced with the entity as |
|
185 |
// saved. This will allow any original entity comparisons in the current |
|
186 |
// save process to react to the most recently saved version of the entity. |
|
187 |
if (!empty($entity->{$this->idKey})) { |
|
186 | 188 |
// In order to properly work in case of name changes, load the original |
187 | 189 |
// entity using the id key if it is available. |
188 | 190 |
$entity->original = entity_load_unchanged($this->entityType, $entity->{$this->idKey}); |
... | ... | |
243 | 245 |
|
244 | 246 |
// Ignore slave server temporarily. |
245 | 247 |
db_ignore_slave(); |
246 |
unset($entity->is_new); |
|
248 |
|
|
249 |
// We unset the original version of the entity after the current save as |
|
250 |
// it no longer accurately represents the version of the entity saved in |
|
251 |
// the database. However, if this save was invoked during a previous |
|
252 |
// save's insert or update hook, this means that any hook implementations |
|
253 |
// executing after this save will no longer have an original version of |
|
254 |
// the entity to compare against. Attempting to compare against the non- |
|
255 |
// existent original entity in code or Rules will result in an error. |
|
247 | 256 |
unset($entity->original); |
257 |
unset($entity->is_new); |
|
248 | 258 |
unset($entity->revision); |
249 | 259 |
|
250 | 260 |
return $return; |
Formats disponibles : Unified diff
Weekly update of contrib modules