Révision 73a44071
Ajouté par Assos Assos il y a plus de 8 ans
drupal7/sites/all/modules/uuid/uuid.core.inc | ||
---|---|---|
35 | 35 |
} |
36 | 36 |
} |
37 | 37 |
|
38 |
/** |
|
39 |
* Implements hook_entity_uuid_save(). |
|
40 |
*/ |
|
41 |
function node_entity_uuid_save(&$entity, $entity_type) { |
|
42 |
// When a node is translated, the source node's tnid is set to it's own nid. When deploying |
|
43 |
// the node for the first time the tnid can't be translated to an nid until after the node has been saved. |
|
44 |
// So if the entity's tnid is still a uuid at this point it needs to be translated to an nid. |
|
45 |
if ($entity_type == 'node' && uuid_is_valid($entity->tnid)) { |
|
46 |
entity_property_uuid_to_id($entity, 'node', 'tnid'); |
|
47 |
db_update('node') |
|
48 |
->fields(array('tnid' => $entity->tnid)) |
|
49 |
->condition('nid', $entity->nid) |
|
50 |
->execute(); |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
38 | 54 |
/** |
39 | 55 |
* Implements hook_entity_uuid_load(). |
40 | 56 |
*/ |
... | ... | |
311 | 327 |
|
312 | 328 |
/** |
313 | 329 |
* Implements hook_field_uuid_load(). |
314 |
*/ |
|
315 |
function node_reference_field_uuid_load($entity_type, $entity, $field, $instance, $langcode, &$items) { |
|
316 |
entity_property_id_to_uuid($items, 'node', 'nid'); |
|
317 |
} |
|
318 |
|
|
319 |
/** |
|
320 |
* Implements hook_field_uuid_presave(). |
|
321 |
*/ |
|
322 |
function node_reference_field_uuid_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { |
|
323 |
entity_property_uuid_to_id($items, 'node', 'nid'); |
|
324 |
} |
|
325 |
|
|
326 |
/** |
|
327 |
* Implements hook_field_uuid_load(). |
|
328 |
*/ |
|
329 |
function user_reference_field_uuid_load($entity_type, $entity, $field, $instance, $langcode, &$items) { |
|
330 |
entity_property_id_to_uuid($items, 'user', 'uid'); |
|
331 |
} |
|
332 |
|
|
333 |
/** |
|
334 |
* Implements hook_field_uuid_presave(). |
|
335 |
*/ |
|
336 |
function user_reference_field_uuid_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { |
|
337 |
entity_property_uuid_to_id($items, 'user', 'uid'); |
|
338 |
} |
|
339 |
|
|
340 |
/** |
|
341 |
* Implements hook_field_uuid_load(). |
|
330 |
* Kept here because it is in D8 core. |
|
342 | 331 |
*/ |
343 | 332 |
function entityreference_field_uuid_load($entity_type, $entity, $field, $instance, $langcode, &$items) { |
344 | 333 |
// TODO: This is not really good, but as of now 'entity_property_id_to_uuid()' |
... | ... | |
348 | 337 |
|
349 | 338 |
/** |
350 | 339 |
* Implements hook_field_uuid_presave(). |
340 |
* Kept here because it is in D8 core. |
|
351 | 341 |
*/ |
352 | 342 |
function entityreference_field_uuid_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { |
353 | 343 |
// TODO: This is not really good, but as of now 'entity_property_id_to_uuid()' |
... | ... | |
355 | 345 |
entity_property_uuid_to_id($items, $field['settings']['target_type'], 'target_id'); |
356 | 346 |
} |
357 | 347 |
|
358 |
/** |
|
359 |
* Implements hook_entity_uuid_load(). |
|
360 |
*/ |
|
361 |
function field_collection_entity_uuid_load(&$entities, $entity_type) { |
|
362 |
if ($entity_type == 'field_collection_item') { |
|
363 |
entity_property_id_to_uuid($entities, 'field_collection_item', 'value'); |
|
364 |
} |
|
365 |
} |
|
366 |
|
|
367 |
/** |
|
368 |
* Implements hook_entity_uuid_presave(). |
|
369 |
*/ |
|
370 |
function field_collection_entity_uuid_presave(&$entity, $entity_type) { |
|
371 |
if ($entity_type == 'field_collection_item') { |
|
372 |
entity_property_uuid_to_id($entity, 'field_collection_item', 'value'); |
|
373 |
} |
|
374 |
} |
|
375 |
|
|
376 |
/** |
|
377 |
* Implements hook_field_uuid_load(). |
|
378 |
*/ |
|
379 |
function field_collection_field_uuid_load($entity_type, $entity, $field, $instance, $langcode, &$items) { |
|
380 |
entity_property_id_to_uuid($items, 'field_collection_item', 'value'); |
|
381 |
} |
|
382 |
|
|
383 |
/** |
|
384 |
* Implements hook_field_uuid_presave(). |
|
385 |
*/ |
|
386 |
function field_collection_field_uuid_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { |
|
387 |
entity_property_uuid_to_id($items, 'field_collection_item', 'value'); |
|
388 |
} |
|
389 |
|
|
390 | 348 |
/** |
391 | 349 |
* @} End of "Field implementations" |
392 | 350 |
*/ |
... | ... | |
433 | 391 |
} |
434 | 392 |
} |
435 | 393 |
|
436 |
/** |
|
437 |
* Implements hook_uuid_entities_features_export_entity_alter(). |
|
438 |
*/ |
|
439 |
function workbench_uuid_entities_features_export_entity_alter(&$entity, $entity_type) { |
|
440 |
foreach (array('workbench_moderation', 'my_revision', 'workbench_access', 'workbench_access_scheme', 'workbench_access_by_role') as $property) { |
|
441 |
if (isset($entity->{$property})) { |
|
442 |
unset($entity->{$property}); |
|
443 |
} |
|
444 |
} |
|
445 |
} |
|
446 |
|
|
447 | 394 |
/** |
448 | 395 |
* @} End of "Export alterations" |
449 | 396 |
*/ |
Formats disponibles : Unified diff
Weekly update of contrib modules