uuid.admin.inc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * @file
  4. * Administration functions for the uuid module.
  5. */
  6. /**
  7. * Menu callback: options for UUID.
  8. */
  9. function uuid_admin_form() {
  10. $form = array();
  11. $form['sync'] = array(
  12. '#type' => 'fieldset',
  13. '#title' => t('Synchronization'),
  14. );
  15. $form['sync']['submit'] = array(
  16. '#type' => 'submit',
  17. '#value' => t('Create missing UUIDs'),
  18. '#submit' => array('uuid_admin_sync_submit'),
  19. );
  20. return system_settings_form($form);
  21. }
  22. /**
  23. * Submit handler for the UUID sync.
  24. */
  25. function uuid_admin_sync_submit() {
  26. uuid_sync_all();
  27. drupal_set_message(t('Generated missing UUIDs.'));
  28. }
  29. /**
  30. * Page callback to display Devel information about a UUID entity.
  31. */
  32. function uuid_devel_load_by_uuid($entity_type, $entity) {
  33. $info = entity_get_info($entity_type);
  34. if (isset($info['uuid']) && $info['uuid'] == TRUE && !empty($info['entity keys']['uuid'])) {
  35. // Get the keys for local ID and UUID.
  36. $uuid_key = $info['entity keys']['uuid'];
  37. $uuid_entities = entity_uuid_load($entity_type, array($entity->{$uuid_key}));
  38. // @codingStandardsIgnoreStart
  39. return kdevel_print_object(reset($uuid_entities), '$' . $entity_type . '->');
  40. // @codingStandardsIgnoreEnd
  41. }
  42. else {
  43. return t("This entity doesn't support UUID.");
  44. }
  45. }