Projet

Général

Profil

Révision e7101f36

Ajouté par Julien Enselme il y a environ 9 ans

Update uuid 1.0-alpha5 1.0-alpha6

Voir les différences:

drupal7/sites/all/modules/uuid/plugins/arguments/entity_uuid.inc
17 17
  'get children' => 'uuid_entity_uuid_get_children',
18 18
);
19 19

  
20
/**
21
 * @todo document me properly
22
 */
20 23
function uuid_entity_uuid_get_child($plugin, $parent, $child) {
21 24
  $plugins = uuid_entity_uuid_get_children($plugin, $parent);
22 25
  return $plugins[$parent . ':' . $child];
23 26
}
24 27

  
28
/**
29
 * @todo document me properly
30
 */
25 31
function uuid_entity_uuid_get_children($original_plugin, $parent) {
26 32
  $entities = entity_get_info();
27 33
  $plugins = array();
drupal7/sites/all/modules/uuid/uuid.api.php
121 121
/**
122 122
 * Let other modules do things before default entities are created on revert.
123 123
 */
124
function hook_uuid_entities_pre_rebuild($plan_name) {
124
function hook_uuid_entities_pre_revert($plan_name) {
125 125

  
126 126
}
127 127

  
128 128
/**
129 129
 * Let other modules do things after default entities are created on revert.
130 130
 */
131
function hook_uuid_entities_post_rebuild($plan_name) {
131
function hook_uuid_entities_post_revert($plan_name) {
132 132

  
133 133
}
134 134

  
......
152 152
function hook_uuid_uri_data($data) {
153 153
}
154 154

  
155
/**
156
 * Alter UUID URI data after processing.
157
 */
158
function hook_uuid_uri_data($data) {
159
}
160

  
161 155
/**
162 156
 * Alter entity URI before creating UUID URI.
163 157
 */
drupal7/sites/all/modules/uuid/uuid.core.inc
125 125
function file_entity_uuid_presave(&$entity, $entity_type) {
126 126
  if ($entity_type == 'file') {
127 127
    entity_property_uuid_to_id($entity, 'user', 'uid');
128

  
129
    // Write the new file to the local filesystem.
128 130
    if (isset($entity->file_contents)) {
129
      $directory = drupal_dirname($entity->uri);
131
      // Don't try to write it if it uses a stream wrapper that isn't writeable
132
      // (for example, if it is a remotely-hosted video).
133
      $scheme = file_uri_scheme($entity->uri);
134
      $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE);
135
      if (empty($wrappers[$scheme])) {
136
        return;
137
      }
138

  
139
      // Check for an existing file with the same URI.
140
      $existing_files = file_load_multiple(array(), array('uri' => $entity->uri));
141
      $existing = (object) array('uri' => NULL, 'uuid' => NULL);
142
      if (count($existing_files)) {
143
        $existing = reset($existing_files);
144
      }
145

  
146
      // If this is a new file and there is an existing file with the same URI,
147
      // but a different uuid then rename this file.
148
      if ($entity->is_new && $entity->uri == $existing->uri && $entity->uuid != $existing->uuid) {
149
        $uri = $entity->uri;
150
        $replace = FILE_EXISTS_RENAME;
151
      }
152
      // If this has an id, meaning UUID has already matched the uuid to an
153
      // existing file, but it has a URI that matches a file with a different
154
      // uuid, then load the file with the matching uuid and use the URI from
155
      // that file. The existing file with the matching uuid is most likely a
156
      // file that was previously renamed, e.g. as in the condition above, to
157
      // avoid conflict. The uuid matches because they are the same file, but
158
      // the URI does not because an incrementing number was added as part of
159
      // the renaming.
160
      elseif ($entity->uri == $existing->uri && $entity->uuid != $existing->uuid) {
161
        $file = file_load($entity->fid);
162
        $uri = $file->uri;
163
        $replace = FILE_EXISTS_REPLACE;
164
      }
165
      // Otherwise create a new file or replace the existing file contents.
166
      else {
167
        $uri = $entity->uri;
168
        $replace = FILE_EXISTS_REPLACE;
169
      }
170

  
171
      $directory = drupal_dirname($uri);
130 172
      file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
131
      file_unmanaged_save_data(base64_decode($entity->file_contents), $entity->uri, FILE_EXISTS_REPLACE);
173
      $entity->uri = file_unmanaged_save_data(base64_decode($entity->file_contents), $uri, $replace);
132 174
    }
133 175
  }
134 176
}
......
368 410
}
369 411

  
370 412
/**
371
 * Implementation of hook_uuid_entities_features_export_entity_alter().
413
 * Implementations hook_uuid_entities_features_export_entity_alter().
372 414
 */
373 415
function user_uuid_entities_features_export_entity_alter(&$entity, $entity_type) {
374 416
  if ($entity_type == 'user') {
drupal7/sites/all/modules/uuid/uuid.entity.inc
76 76
 */
77 77

  
78 78
/**
79
 * Implements of hook_entity_info_alter().
79
 * Implements hook_entity_info_alter().
80 80
 *
81
 * @see uuid_core_entity_info().
81
 * @see uuid_core_entity_info()
82 82
 */
83 83
function uuid_entity_info_alter(&$info) {
84 84
  foreach (uuid_get_core_entity_info() as $entity_type => $core_info) {
......
91 91
}
92 92

  
93 93
/**
94
 * Implements of hook_entity_property_info_alter().
94
 * Implements hook_entity_property_info_alter().
95 95
 *
96 96
 * This adds the UUID as an entity property for all UUID-enabled entities
97 97
 * which automatically gives us token and Rules integration.
98 98
 */
99 99
function uuid_entity_property_info_alter(&$info) {
100 100
  foreach (entity_get_info() as $entity_type => $entity_info) {
101
    if (isset($entity_info['uuid']) && $entity_info['uuid'] == TRUE && !empty($entity_info['entity keys']['uuid'])) {
101
    if (isset($entity_info['uuid']) && $entity_info['uuid'] == TRUE 
102
      && !empty($entity_info['entity keys']['uuid'])
103
      && empty($info[$entity_type]['properties'][$entity_info['entity keys']['uuid']])) {
102 104
      $info[$entity_type]['properties'][$entity_info['entity keys']['uuid']] = array(
103 105
        'label' => t('UUID'),
104 106
        'type' => 'text',
105 107
        'description' => t('The universally unique ID.'),
106 108
        'schema field' => $entity_info['entity keys']['uuid'],
107 109
      );
108
      if (!empty($entity_info['entity keys']['revision uuid'])) {
110
      if (!empty($entity_info['entity keys']['revision uuid']) 
111
        && empty($info[$entity_type]['properties'][$entity_info['entity keys']['revision uuid']])) {
109 112
        $info[$entity_type]['properties'][$entity_info['entity keys']['revision uuid']] = array(
110 113
          'label' => t('Revision UUID'),
111 114
          'type' => 'text',
......
118 121
}
119 122

  
120 123
/**
121
 * Implements of hook_entity_presave().
124
 * Implements hook_entity_presave().
122 125
 *
123 126
 * This is where all UUID-enabled entities get their UUIDs.
124 127
 */
......
131 134
    }
132 135
    if (!empty($info['entity keys']['revision uuid'])) {
133 136
      $vuuid_key = $info['entity keys']['revision uuid'];
134
      if ((isset($entity->revision) && $entity->revision == TRUE) || empty($entity->{$vuuid_key})) {
137
      // If this entity comes from a remote environment and have a revision UUID
138
      // that exists locally we should not create a new revision. Because
139
      // otherwise revisions won't be tracked universally.
140
      // TODO: Move code dependent on the uuid_services module into it's own
141
      // implementation of hook_entity_presave().
142
      if (!empty($entity->uuid_services) && isset($entity->{$vuuid_key})) {
143
        $vuuid_exists = (bool) entity_get_id_by_uuid($entity_type, array($entity->{$vuuid_key}), TRUE);
144
        if ($vuuid_exists) {
145
          $entity->revision = FALSE;
146
        }
147
      }
148

  
149
      if ((isset($entity->revision) && $entity->revision == TRUE && empty($entity->uuid_services)) || empty($entity->{$vuuid_key})) {
135 150
        $entity->{$vuuid_key} = uuid_generate();
136 151
      }
137 152
    }
......
151 166
/**
152 167
 * Load entities by their UUID, that only should containing UUID references.
153 168
 *
169
 * Optionally load revisions by their VUUID by passing it into $conditions.
170
 * Ex. $conditions['vuuid'][$vuuid]
171
 *
154 172
 * This function is mostly useful if you want to load an entity from the local
155 173
 * database that only should contain UUID references.
156 174
 *
157 175
 * @see entity_load()
158 176
 */
159 177
function entity_uuid_load($entity_type, $uuids = array(), $conditions = array(), $reset = FALSE) {
178
  // Allow Revision UUID to be passed in $conditions and translate.
179
  $entity_info[$entity_type] = entity_get_info($entity_type);
180
  $revision_key = $entity_info[$entity_type]['entity keys']['revision'];
181
  if (isset($entity_info[$entity_type]['entity keys']['revision uuid'])) {
182
    $revision_uuid_key = $entity_info[$entity_type]['entity keys']['revision uuid'];
183
  }
184
  if (isset($revision_uuid_key) && isset($conditions[$revision_uuid_key])) {
185
    $revision_id = entity_get_id_by_uuid($entity_type, array($conditions[$revision_uuid_key]), TRUE);
186
    $conditions[$revision_key] = $revision_id[$conditions[$revision_uuid_key]];
187
    unset($conditions[$revision_uuid_key]);
188
  }
160 189
  $ids = entity_get_id_by_uuid($entity_type, $uuids);
161 190
  $results = entity_load($entity_type, $ids, $conditions, $reset);
162 191
  $entities = array();
......
209 238
    throw new UuidEntityException(t('Calling %function requires the Entity API module (!link).', array('%function' => __FUNCTION__, '!link' => 'http://drupal.org/project/entity')));
210 239
  }
211 240

  
241
  $info = entity_get_info($entity_type);
242
  $uuid_key = $info['entity keys']['uuid'];
243
  if (empty($entity->{$uuid_key}) || !uuid_is_valid($entity->{$uuid_key})) {
244
    watchdog('Entity UUID', 'Attempted to save an entity with an invalid UUID', array(), WATCHDOG_ERROR);
245
    return FALSE;
246
  }
247

  
248
  // Falling back on the variable node_options_[type] is not something an API
249
  // function should take care of. With normal (non UUID) nodes this is dealt
250
  // with in the form submit handler, i.e. not in node_save().
251
  // But since using entity_uuid_save() usually means you're trying to manage
252
  // entities remotely we do respect this variable here to make it work as the
253
  // node form, but only if we explicitly haven't set $node->revision already.
254
  if ($entity_type == 'node' && !isset($entity->revision) && in_array('revision', variable_get('node_options_' . $entity->type, array()))) {
255
    $entity->revision = 1;
256
  }
257

  
212 258
  entity_make_entity_local($entity_type, $entity);
213 259

  
214 260
  // Save the entity.
......
259 305
      $vid = NULL;
260 306
      // Fetch the local revision ID by its UUID.
261 307
      if (isset($entity->{$vuuid_key})) {
308
        // It's important to note that the revision UUID might be set here but
309
        // there might not exist a correspondant local revision ID in which case
310
        // we should unset the assigned revision ID to not confuse anyone with
311
        // revision IDs that might come from other environments.
262 312
        $vids = entity_get_id_by_uuid($entity_type, array($entity->{$vuuid_key}), TRUE);
263 313
        $vid = reset($vids);
264 314
      }
......
268 318
      elseif (!empty($vid)) {
269 319
        $entity->{$vid_key} = $vid;
270 320
      }
271
      // Nodes need this when trying to save an existing node without a vid.
321
      // If the revision ID was unset before this (or just missing for some
322
      // reason) we fetch the current revision ID to build a better
323
      // representation of the node object we're working with.
272 324
      if ($entity_type == 'node' && !isset($entity->vid) && !$entity->is_new) {
273
        $entity->revision = 0;
274 325
        $entity->vid = db_select('node', 'n')
275 326
          ->condition('n.nid', $entity->nid)
276 327
          ->fields('n', array('vid'))
......
312 363
    // Fetch the local ID by its UUID.
313 364
    $ids = entity_get_id_by_uuid($entity_type, array($uuid));
314 365
    $id = reset($ids);
366
    $entity = entity_load($entity_type, array($id));
315 367

  
316 368
    // Let other modules transform UUID references to local ID references.
317 369
    $hook = 'entity_uuid_delete';
......
322 374
      }
323 375
    }
324 376

  
377
    if (empty($entity)) {
378
      return FALSE;
379
    }
325 380
    // Delete the entity.
326 381
    return entity_delete($entity_type, $id);
327 382
  }
drupal7/sites/all/modules/uuid/uuid.features.inc
93 93
      // Let other modules alter exported entities.
94 94
      drupal_alter('uuid_entities_features_export_entity', $entity, $entity_type);
95 95
      // Field handling.
96
      list(,, $bundle_name) = entity_extract_ids($entity_type, $entity);
96
      list(, , $bundle_name) = entity_extract_ids($entity_type, $entity);
97 97
      $instances = field_info_instances($entity_type, $bundle_name);
98 98
      foreach ($instances as $field_name => $instance) {
99 99
        $field = field_info_field($field_name);
drupal7/sites/all/modules/uuid/uuid.inc
166 166

  
167 167
/**
168 168
 * Generates a UUID v4 using PHP code.
169
 * 
170
 * Based on code from @see http://php.net/uniqid#65879 , but corrected.
169
 *
170
 * Based on code from http://php.net/uniqid#65879, but corrected.
171 171
 */
172 172
function _uuid_generate_php() {
173 173
  // The field names refer to RFC 4122 section 4.1.2.
......
188 188

  
189 189

  
190 190
// This is wrapped in an if block to avoid conflicts with PECL's uuid_is_valid().
191
/**
192
 * Check that a string appears to be in the format of a UUID.
193
 *
194
 * @param $uuid
195
 *  The string to test.
196
 *
197
 * @return
198
 *   TRUE if the string is well formed.
199
 */
200 191
if (!function_exists('uuid_is_valid')) {
192
  /**
193
   * Check that a string appears to be in the format of a UUID.
194
   *
195
   * @param $uuid
196
   *  The string to test.
197
   *
198
   * @return
199
   *   TRUE if the string is well formed.
200
   */
201 201
  function uuid_is_valid($uuid) {
202 202
    return preg_match('/^' . UUID_PATTERN . '$/', $uuid);
203 203
  }
drupal7/sites/all/modules/uuid/uuid.info
4 4
package = UUID
5 5
configure = admin/config/system/uuid
6 6
files[] = uuid.test
7
dependencies[] = node
8
dependencies[] = user
7 9

  
8
; Information added by drupal.org packaging script on 2013-07-12
9
version = "7.x-1.0-alpha5"
10
; Information added by Drupal.org packaging script on 2014-09-23
11
version = "7.x-1.0-alpha6"
10 12
core = "7.x"
11 13
project = "uuid"
12
datestamp = "1373620283"
14
datestamp = "1411455150"
13 15

  
drupal7/sites/all/modules/uuid/uuid.install
29 29
}
30 30

  
31 31
/**
32
 * Implements of hook_schema_alter().
32
 * Implements hook_schema_alter().
33 33
 */
34 34
function uuid_schema_alter(&$schema = array()) {
35 35
  $field = uuid_schema_field_definition();
......
230 230
  _uuid_install_uuid_fields();
231 231
  uuid_sync_all();
232 232
}
233

  
234
/**
235
 * Modify the labels of all example entities created by the now removed
236
 * uuid_default_entities_example.module to make it clear they're examples.
237
 * Also remove the administrator role of any example user.
238
 */
239
function uuid_update_7103() {
240
  // These are UUIDs of all the example entities that might exist after having
241
  // installed uuid_default_entities_example.module.
242
  $info = entity_get_info();
243
  $uuids = array(
244
    'node' => array(
245
      'b0558664-c94b-3674-d9df-3e1696b2e471',
246
      '5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837',
247
    ),
248
    'user' => array(
249
      '7cf875e6-dc15-4404-f190-5a7c3e91d14c',
250
    ),
251
  );
252
  // we can't assume taxonomy is enabled
253
  if (isset($info['taxonomy_term'])) {
254
    $uuids['taxonomy_term'] = array(
255
      'bcb92ce8-2236-e264-65c8-0c163ae716d1',
256
      '4293a15c-531a-6164-7d1b-668ed019a6bd',
257
      'af738a46-f278-cf84-d94d-9e03879fd71e',
258
    );
259
  }
260
  foreach (array_keys($uuids) as $entity_type) {
261
    $info = entity_get_info($entity_type);
262
    $entity_ids = entity_get_id_by_uuid($entity_type, $uuids[$entity_type]);
263
    $entities = entity_load($entity_type, $entity_ids);
264
    foreach ($entities as $entity) {
265
      // Update the label to make it clear this is example content.
266
      $entity->{$info['entity keys']['label']} = $entity->{$info['entity keys']['label']} . ' (UUID example)';
267
      // Remove the administrator role from any user.
268
      if ($entity_type == 'user' && $rid = array_search('administrator', $entity->roles)) {
269
        unset($entity->roles[$rid]);
270
      }
271
      entity_save($entity);
272
    }
273
  }
274
}
drupal7/sites/all/modules/uuid/uuid.module
25 25
module_load_include('inc', 'uuid', 'uuid.core');
26 26

  
27 27
/**
28
 * Implements of hook_menu().
28
 * Implements hook_menu().
29 29
 */
30 30
function uuid_menu() {
31 31
  $items = array();
......
72 72
}
73 73

  
74 74
/**
75
 * Implements of hook_ctools_plugin_directory().
75
 * Implements hook_ctools_plugin_directory().
76 76
 */
77 77
function uuid_ctools_plugin_directory($module, $plugin) {
78 78
  if ($module == 'ctools') {
......
81 81
}
82 82

  
83 83
/**
84
 * Implements of hook_permission().
84
 * Implements hook_permission().
85 85
 */
86 86
function uuid_permission() {
87 87
  return array(
......
125 125

  
126 126

  
127 127
/**
128
 * Implementation of hook_views_api().
128
 * Implements hook_views_api().
129 129
 */
130 130
function uuid_views_api() {
131 131
  return array(
......
135 135
}
136 136

  
137 137
/**
138
 * Implements of hook_module_implements_alter().
138
 * Implements hook_module_implements_alter().
139 139
 *
140
 * Moves implementation of hook_entity_info_alter() to the bottom so it is
140
 * Moves hook_entity_info_alter() implementation to the bottom so it is
141 141
 * invoked after all modules relying on the entity API.
142 142
 *
143 143
 * @see uuid_entity_info_alter()
144 144
 */
145
function uuid_module_implements_alter(&$Implementss, $hook) {
145
function uuid_module_implements_alter(&$implementss, $hook) {
146 146
  if ($hook == 'entity_info_alter') {
147 147
    // Move our hook Implements to the bottom.
148
    $group = $Implementss['uuid'];
149
    unset($Implementss['uuid']);
150
    $Implementss['uuid'] = $group;
148
    $group = $implementss['uuid'];
149
    unset($implementss['uuid']);
150
    $implementss['uuid'] = $group;
151 151
  }
152 152
}
153 153

  
154 154
/**
155
 * Implements of hook_uuid_sync().
155
 * Implements hook_uuid_sync().
156 156
 */
157 157
function uuid_uuid_sync() {
158 158
  foreach (entity_get_info() as $entity_type => $info) {
......
185 185
}
186 186

  
187 187
/**
188
 * Implementation of hook_features_api().
188
 * Implements hook_features_api().
189 189
 *
190 190
 * The Features support consists of exporting entities from a Deploy
191 191
 * <em>fetch-only</em> plan. Deploy is only required to generate the feature
......
202 202
      'default_hook' => 'uuid_default_entities',
203 203
      'default_file' => FEATURES_DEFAULTS_INCLUDED,
204 204
      'feature_source' => TRUE,
205
      'file' => drupal_get_path('module', 'uuid') .'/uuid.features.inc',
205
      'file' => drupal_get_path('module', 'uuid') . '/uuid.features.inc',
206 206
    ),
207 207
  );
208 208
}
......
212 212
 */
213 213
function uuid_redirector() {
214 214
  $entity_data = uuid_uri_array_to_data(arg());
215
  
215

  
216 216
  $entity_info = entity_get_info($entity_data['entity_type']);
217 217
  if (empty($entity_info['uuid'])) {
218 218
    return drupal_not_found();
drupal7/sites/all/modules/uuid/uuid.test
10 10
 */
11 11
class UUIDTestCase extends DrupalWebTestCase {
12 12

  
13
  /**
14
   * {@inheritdoc}
15
   */
13 16
  function setUp() {
14 17
    parent::setUp(func_get_args());
15 18
  }
......
27 30
 */
28 31
class UUIDAPITestCase extends UUIDTestCase {
29 32

  
33
  /**
34
   * {@inheritdoc}
35
   */
30 36
  public static function getInfo() {
31 37
    return array(
32 38
      'name' => 'UUID API',
......
35 41
    );
36 42
  }
37 43

  
44
  /**
45
   * {@inheritdoc}
46
   */
38 47
  function setUp() {
39 48
    parent::setUp('uuid');
40 49
  }
41 50

  
51
  /**
52
   * Tests uuid function calls.
53
   */
42 54
  function testAPIFunctions() {
43 55
    // This is a valid UUID, we know that.
44 56
    $valid_uuid = '0ab26e6b-f074-4e44-9da6-1205fa0e9761';
......
62 74
 */
63 75
class UUIDEntityTestCase extends UUIDTestCase {
64 76

  
77
  /**
78
   * {@inheritdoc}
79
   */
65 80
  public static function getInfo() {
66 81
    return array(
67 82
      'name' => 'Entity API functions',
......
70 85
    );
71 86
  }
72 87

  
88
  /**
89
   * {@inheritdoc}
90
   */
73 91
  function setUp() {
74 92
    parent::setUp('uuid');
75 93
  }
......
101 119
 */
102 120
class UUIDUserTestCase extends UUIDTestCase {
103 121

  
122
  /**
123
   * {@inheritdoc}
124
   */
104 125
  public static function getInfo() {
105 126
    return array(
106 127
      'name' => 'User implementation',
......
109 130
    );
110 131
  }
111 132

  
133
  /**
134
   * {@inheritdoc}
135
   */
112 136
  function setUp() {
113 137
    // Some tests depends on the optional Entity API module.
114 138
    if (module_exists('entity')) {
......
161 185
 */
162 186
class UUIDNodeTestCase extends UUIDTestCase {
163 187

  
188
  /**
189
   * {@inheritdoc}
190
   */
164 191
  public static function getInfo() {
165 192
    return array(
166 193
      'name' => 'Node implementation',
......
169 196
    );
170 197
  }
171 198

  
199
  /**
200
   * {@inheritdoc}
201
   */
172 202
  function setUp() {
173 203
    // Some tests depends on the optional Entity API module.
174 204
    if (module_exists('entity')) {
......
181 211

  
182 212
  /**
183 213
   * Tests CRUD on nodes with UUID functions.
214
   *
215
   * @todo
216
   *   Break out into multiple test methods to loosen coupling between tests.
184 217
   */
185 218
  function testNodeCRUD() {
186 219
    // Create some entities that we will work with.
......
192 225

  
193 226
    // Test node update, without creating new revision.
194 227
    $node_test = clone $node;
195
    $node_test->title = 'new title';
228
    $node_test->title = 'original title';
196 229
    $node_test->revision = FALSE;
197 230
    node_save($node_test);
198 231
    $node_test = node_load($node->nid, FALSE, TRUE);
199 232
    $this->assertEqual($node_test->uuid, $node->uuid, 'Node UUID was intact after update, when not creating new revision.');
200 233
    $this->assertEqual($node_test->vuuid, $node->vuuid, 'Node revision UUID was intact after updating, when not creating new revision.');
234
    // Save the original revision IDs that we will test with later.
235
    $vid_old = $node_test->vid;
236
    $vuuid_old = $node_test->vuuid;
237
    $uuid_old = $node_test->uuid;
201 238

  
202 239
    // Test node update, with new revision.
203 240
    $node_test = clone $node;
......
210 247
    $this->assertUUID($node_test->vuuid, 'The new node revision UUID was valid.');
211 248

  
212 249
    // Test entity_uuid_load().
250
    // Save some variables that we will test against.
251
    $nid_test = $node_test->nid;
252
    $vid_test = $node_test->vid;
253
    $uid_test = $user->uuid;
254
    $uuid_test = $node_test->uuid;
255
    $vuuid_test = $node_test->vuuid;
213 256
    $nodes = entity_uuid_load('node', array($node->uuid), array(), TRUE);
214 257
    $node_test = reset($nodes);
215
    $this->assertEqual($node_test->nid, $node->nid, 'Node was correctly loaded with UUID.');
216
    $this->assertEqual($node_test->uid, $user->uuid, "Node property 'uid' was transformed to UUID when loaded with UUID.");
258
    $this->assertEqual($node_test->nid, $nid_test, 'Node ID was correct when loading with UUID.');
259
    $this->assertEqual($node_test->vid, $vid_test, 'Node revision ID was correct when loading with UUID.');
260
    $this->assertEqual($node_test->uid, $uid_test, "Node author ID was transformed to UUID when loaded with UUID.");
261
    $this->assertEqual($node_test->uuid, $uuid_test, 'Node UUID was correct when loading with UUID.');
262
    $this->assertEqual($node_test->vuuid, $vuuid_test, 'Node revision UUID was correct when loading with UUID.');
263

  
264
    // Test entity_uuid_load() with conditions.
265
    // Load the previous revision UUID that we saved earlier.
266
    $nodes = entity_uuid_load('node', array($uuid_test), array('vuuid' => $vuuid_old));
267
    $node_test = reset($nodes);
268
    $this->assertTrue((($node_test->uuid == $uuid_test) && ($node_test->nid && $node->nid)), 'The correct entity was loaded when loading a universal entity with a revision UUID condition.');
269
    $this->assertEqual($node_test->vuuid, $vuuid_old, 'Correct revision UUID was loaded when loading a universal entity with a revision UUID condition.');
270
    $this->assertEqual($node_test->vid, $vid_old, 'Correct revision ID was loaded when loading a universal entity with a revision UUID condition.');
271
    $this->assertEqual($node_test->title, 'original title', 'Correct title was loaded when loading a universal entity with a revision UUID condition.');
217 272

  
218 273
    // The following tests depends on the optional Entity API module.
219 274
    if (module_exists('entity')) {
......
248 303
      $this->assertUUID($node_test->vuuid, 'New node revision UUID was valid.');
249 304
      $this->assertEqual($node_test->uid, $node->uid, "Node property 'uid' was intact after saving with UUID, when creating new revision.");
250 305

  
306
      // Test the same thing again, but now triggering a new revision from a
307
      // remote environment.
308
      // TODO: Move this test to the uuid_services module.
309
      $nodes = entity_uuid_load('node', array($node->uuid), array(), TRUE);
310
      $node_test = reset($nodes);
311
      // Store the current local revision ID to test with later.
312
      $vid_old1 = $node_test->vid;
313
      $vuuid_old1 = $node_test->vuuid;
314
      // Simulate this node coming from a remote environment by generating
315
      // IDs that won't match. Only the UUID match at this point.
316
      $node_test->uuid_services = TRUE;
317
      $nid_remote = rand();
318
      $vid_remote = rand();
319
      $vuuid_test = uuid_generate();
320
      $node_test->nid = $nid_test;
321
      $node_test->vid = $vid_test;
322
      $node_test->vuuid = $vuuid_test;
323
      $node_test->revision = TRUE;
324
      entity_uuid_save('node', $node_test);
325
      $node_test = node_load($node->nid, FALSE, TRUE);
326
      $this->assertNotEqual($node_test->vid, $vid_old1, 'A new revision was created, when trying to create new revision with new revision UUID from remote site');
327
      $this->assertEqual($node_test->vuuid, $vuuid_test, 'The revison UUID was preserved after saving with UUID, when trying to create new revision with new revision UUID from remote site.');
328

  
329
      // Test the same thing again from a remote environment, but now with the
330
      // same vuuid as once previosuly. This should not trigger a new revision.
331
      // This covers the case of "dupe deployments" where a client might push a
332
      // node several times.
333
      // TODO: Move this test to the uuid_services module.
334
      $nodes = entity_uuid_load('node', array($node->uuid), array(), TRUE);
335
      $node_test = reset($nodes);
336
      // Store the current local revision ID to test with later.
337
      $vid_old2 = $node_test->vid;
338
      // Simulate this node coming from a remote environment by generating
339
      // IDs that won't match.
340
      $node_test->uuid_services = TRUE;
341
      $node_test->nid = $nid_test;
342
      $node_test->vid = $vid_test;
343
      $node_test->vuuid = $vuuid_test;
344
      $node_test->revision = TRUE;
345
      entity_uuid_save('node', $node_test);
346
      $node_test = node_load($node->nid, FALSE, TRUE);
347
      $this->assertEqual($node_test->vid, $vid_old2, 'A new revision was not created, when trying to create new revision with existing revision UUID from remote site.');
348
      $this->assertEqual($node_test->vuuid, $vuuid_test, 'The revison UUID was preserved after saving with UUID, when trying to create new revision with existing revision UUID from remote site.');
349

  
350
      // Test the same this again, but now with an old revision.
351
      $nodes = entity_uuid_load('node', array($uuid_old), array('vuuid' => $vuuid_old), TRUE);
352
      $node_test = reset($nodes);
353
      // Simulate this node coming from a remote environment by generating
354
      // IDs that won't match.
355
      $node_test->uuid_services = TRUE;
356
      $node_test->nid = rand();
357
      $node_test->vid = rand();
358
      $node_test->revision = TRUE;
359
      $node_test->title = 'newest title';
360
      entity_uuid_save('node', $node_test);
361
      $node_test = node_load($node->nid, $vid_old, TRUE);
362
      $this->assertEqual($node_test->title, 'newest title', 'The revision was updated, when updating old revision with existing revision UUID from remote site.');
363
      $this->assertEqual($node_test->vuuid, $vuuid_old, 'The revison UUID was preserved after saving with UUID, when updating old revision with existing revision UUID from remote site.');
364

  
365
      // Setting the node options variable should also trigger a new revision.
366
      $nodes = entity_uuid_load('node', array($node->uuid), array(), TRUE);
367
      $node_test = reset($nodes);
368
      variable_set('node_options_' . $node_test->type, array('revision'));
369
      entity_uuid_save('node', $node_test);
370
      $this->assertNotEqual($node_test->vuuid, $node->vuuid, 'A new node revison ID was generated after saving with UUID, when relying on the node options variable.');
371

  
251 372
      // Test entity_uuid_delete() for nodes.
252 373
      entity_uuid_delete('node', $node->uuid);
253 374
      $node_test = node_load($node->nid);
......
264 385
 */
265 386
class UUIDCommentTestCase extends CommentHelperCase {
266 387

  
388
  /**
389
   * {@inheritdoc}
390
   */
267 391
  public static function getInfo() {
268 392
    return array(
269 393
      'name' => 'Comment implementation',
......
339 463
 */
340 464
class UUIDTaxonomyTestCase extends TaxonomyWebTestCase {
341 465

  
466
  /**
467
   * {@inheritdoc}
468
   */
342 469
  public static function getInfo() {
343 470
    return array(
344 471
      'name' => 'Taxonomy implementation',
......
348 475
  }
349 476

  
350 477
  /**
478
   * {@inheritdoc}
479
   *
351 480
   * A lot of code here is taken from TaxonomyTermTestCase::setUp().
352 481
   */
353 482
  function setUp() {
......
420 549
 */
421 550
class UUIDSyncTestCase extends UUIDTestCase {
422 551

  
552
  /**
553
   * {@inheritdoc}
554
   */
423 555
  public static function getInfo() {
424 556
    return array(
425 557
      'name' => 'UUID sync',
......
435 567
   *   There are something weird around this assertion.
436 568
   */
437 569
  function assertTableColumn($table, $column, $message) {
438
    $result = db_query("SHOW COLUMNS FROM {$table}");
439
    $exists = FALSE;
440
    foreach ($result as $record) {
441
      if ($record->field == $column) {
442
        $exists = TRUE;
443
        break;
444
      }
445
    }
446
    $this->assertTrue($exists, $message);
570
    $this->assertTrue(db_field_exists($table, $column), $message);
447 571
  }
448 572

  
573
  /**
574
   * Tests creating UUIDs for entities that don't have them.
575
   */
449 576
  function testSync() {
450 577
    // These entities will not have UUID from the start, since the UUID module
451 578
    // isn't installed yet.
......
481 608
    $this->assertUUID($user_test->uuid, 'User UUID was generated when clicking the sync button.');
482 609
  }
483 610
}
484

  
485
class UUIDExportEntitiesWithDeploy extends DrupalWebTestCase {
486

  
487
  public static function getInfo() {
488
    return array(
489
      'name' => 'Export UUID entities',
490
      'description' => 'Test exporting UUID entities with Deploy and Features.',
491
      'group' => 'UUID',
492
    );
493
  }
494

  
495
  function setUp() {
496
    parent::setUp('taxonomy', 'uuid', 'entity', 'features', 'deploy', 'deploy_example');
497
  }
498

  
499
  function testExport() {
500
    $test_user = $this->drupalCreateUser();
501
    $test_node = $this->drupalCreateNode(array(
502
      'uid' => $test_user->uid,
503
    ));
504
    deploy_manager_add_to_plan('deploy_example_plan', 'node', $test_node);
505
    // TODO: Test the actual insert.
506
    $this->assertTrue(TRUE, 'Added a node with a user dependency to be exported as a Feature module.');
507

  
508
    // Login and recreate the example feature. The feature isn't installed. But
509
    // Features can still export the code, and we can test it.
510
    $web_user = $this->drupalCreateUser(array('administer features'));
511
    $this->drupalLogin($web_user);
512
    $code = $this->drupalPost('admin/structure/features/uuid_default_entities_example/recreate', array(), t('Download feature'));
513
    $this->assertTrue($code, 'Feature module was exported.');
514

  
515
    // Ensure that we find what we expect in the exported code.
516
    $node_test1 = preg_match('/' . $test_node->title . '/', $code);
517
    $node_test2 = preg_match("/'uri' => 'node\/" . $test_node->uuid . "'/", $code);
518
    $this->assertTrue($node_test1, 'Node title was found in the expoted code.');
519
    $this->assertTrue($node_test2, 'Node URI was found in the expoted code.');
520
    $user_test1 = preg_match('/' . $test_user->name . '/', $code);
521
    $user_test2 = preg_match("/'uri' => 'user\/" . $test_user->uuid . "'/", $code);
522
    $this->assertTrue($user_test1, 'User was found in the expoted code.');
523
    $this->assertTrue($user_test2, 'User URI was found in the expoted code.');
524
  }
525
}
526

  
527
/**
528
 * Tests for the UUID synchronization.
529
 */
530
class UUIDImportEntitiesTestCase extends UUIDTestCase {
531

  
532
  /**
533
   * Representation of the UUIDs that is exported in our example feature, that
534
   * we use for testing.
535
   */
536
  public $term1_uuid = 'bcb92ce8-2236-e264-65c8-0c163ae716d1';
537
  public $term2_uuid = '4293a15c-531a-6164-7d1b-668ed019a6bd';
538
  public $term3_uuid = 'af738a46-f278-cf84-d94d-9e03879fd71e';
539
  public $node1_uuid = 'b0558664-c94b-3674-d9df-3e1696b2e471';
540
  public $node2_uuid = '5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837';
541
  public $user1_uuid = '7cf875e6-dc15-4404-f190-5a7c3e91d14c';
542

  
543
  /**
544
   * Helper method to assert the uuid_entities component in any features.
545
   */
546
  function assertFeatureState($feature, $state, $message = '') {
547
    if (empty($message)) {
548
      switch ($state) {
549
        case FEATURES_DEFAULT:
550
          $readable_state = 'default';
551
          break;
552
        case FEATURES_OVERRIDDEN:
553
          $readable_state = 'overridden';
554
          break;
555
        default:
556
          $readable_state = 'unknown';
557
          break;
558
      }
559
      $message = format_string('%component in %feature had state: %state', array('%component' => 'uuid_entities', '%feature' => $feature, '%state' => $readable_state));
560
    }
561
    // Ensure that the features we used is in default state.
562
    $states = features_get_component_states(array($feature), TRUE, TRUE);
563
    if (!$this->assertEqual($states[$feature]['uuid_entities'], $state, $message)) {
564
      debug(format_string('Enabling functionality to show diff output for debug purposes.'));
565
      $success = module_enable(array('diff'));
566
      if ($success) {
567
        // Make sure we run on cold caches.
568
        drupal_flush_all_caches();
569
        drupal_static_reset();
570

  
571
        $user = $this->drupalCreateUser(array('administer features'));
572
        $this->drupalLogin($user);
573
        $this->drupalGet('admin/structure/features/' . $feature . '/diff');
574
      }
575
      else {
576
        debug(format_string('Download !module to see diff output for debug purposes.', array('!module' => 'diff.module')));
577
      }
578
    }
579
  }
580

  
581
  function getEntityByUuid($entity_type, $uuid) {
582
    $ids = entity_get_id_by_uuid($entity_type, array($uuid));
583
    $entities = entity_load($entity_type, $ids, NULL, TRUE);
584
    return reset($entities);
585
  }
586

  
587
  function enableFeature($feature) {
588
    $success = module_enable(array($feature), TRUE);
589
    $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', array($feature)))));
590
    // Make sure we run on cold caches.
591
    drupal_flush_all_caches();
592
    drupal_static_reset();
593
  }
594

  
595
  function revertFeature($feature) {
596
    features_revert(array($feature => array('uuid_entities')));
597
    $this->assertTrue(TRUE, format_string('Reverted feature: %feature', array('%feature' => $feature)));
598
  }
599

  
600
  function testImport() {
601
    $term1 = $this->getEntityByUuid('taxonomy_term', $this->term1_uuid);
602
    $term2 = $this->getEntityByUuid('taxonomy_term', $this->term2_uuid);
603
    $term3 = $this->getEntityByUuid('taxonomy_term', $this->term3_uuid);
604
    $node1 = $this->getEntityByUuid('node', $this->node1_uuid);
605
    $node2 = $this->getEntityByUuid('node', $this->node2_uuid);
606
    $user1 = $this->getEntityByUuid('user', $this->user1_uuid);
607

  
608
    // Ensure that we don't have our entities yet.
609
    $this->assertTrue(empty($term1), 'Term 1 has not been created yet.');
610
    $this->assertTrue(empty($term2), 'Term 2 has not been created yet.');
611
    $this->assertTrue(empty($term3), 'Term 3 has not been created yet.');
612
    $this->assertTrue(empty($node1), 'Node 1 has not been created yet.');
613
    $this->assertTrue(empty($node2), 'Node 2 has not been created yet.');
614
    $this->assertTrue(empty($user1), 'User 1 has not been created yet.');
615

  
616
    $this->enableFeature('uuid_default_entities_example');
617

  
618
    $term1 = $this->getEntityByUuid('taxonomy_term', $this->term1_uuid);
619
    $term2 = $this->getEntityByUuid('taxonomy_term', $this->term2_uuid);
620
    $term3 = $this->getEntityByUuid('taxonomy_term', $this->term3_uuid);
621
    $node1 = $this->getEntityByUuid('node', $this->node1_uuid);
622
    $node2 = $this->getEntityByUuid('node', $this->node2_uuid);
623
    $user1 = $this->getEntityByUuid('user', $this->user1_uuid);
624

  
625
    // Ensure that our entities was created.
626
    $this->assertEqual($term1->uuid, $this->term1_uuid, 'Term 1 was created.');
627
    $this->assertEqual($term2->uuid, $this->term2_uuid, 'Term 2 was created.');
628
    $this->assertEqual($term3->uuid, $this->term3_uuid, 'Term 3 was created.');
629
    $this->assertEqual($node1->uuid, $this->node1_uuid, 'Node 1 was created.');
630
    $this->assertEqual($node2->uuid, $this->node2_uuid, 'Node 2 was created.');
631
    $this->assertEqual($user1->uuid, $this->user1_uuid, 'User 1 was created.');
632

  
633
    // Check the features state.
634
    $this->assertFeatureState('uuid_default_entities_example', FEATURES_DEFAULT);
635

  
636
    // New property.
637
    $new = 'foo bar';
638
    // Change a term.
639
    $term1->name = $new;
640
    $status = taxonomy_term_save($term1);
641
    $this->assertEqual($status, SAVED_UPDATED, 'Updated term 1.');
642
    // Change a node.
643
    $node1->title = $new;
644
    node_save($node1);
645
    $this->assertEqual($node1->title, $new, 'Updated node 1.');
646
    // Change a user.
647
    $user1->name = $new;
648
    $updated_user = user_save($user1);
649
    $this->assertEqual($user1->name, $updated_user->name, 'Updated user 1.');
650

  
651
    // Check the features state.
652
    $this->assertFeatureState('uuid_default_entities_example', FEATURES_OVERRIDDEN);
653

  
654
    // Revert the feature.
655
    $this->revertFeature('uuid_default_entities_example');
656

  
657
    // Check the features state.
658
    $this->assertFeatureState('uuid_default_entities_example', FEATURES_DEFAULT);
659
  }
660
}
661

  
662
class UUIDImportEntitiesWithDeploy extends UUIDImportEntitiesTestCase {
663

  
664
  public static function getInfo() {
665
    return array(
666
      'name' => 'Import UUID entities, with Deploy',
667
      'description' => 'Test importing UUID entities with Features and Deploy.',
668
      'group' => 'UUID',
669
    );
670
  }
671

  
672
  function setUp() {
673
    parent::setUp('taxonomy', 'uuid', 'entity', 'features', 'deploy', 'deploy_example');
674
  }
675
}
676

  
677
class UUIDImportEntitiesWithoutDeploy extends UUIDImportEntitiesTestCase {
678

  
679
  public static function getInfo() {
680
    return array(
681
      'name' => 'Import UUID entities, without Deploy',
682
      'description' => 'Test importing UUID entities with Features only.',
683
      'group' => 'UUID',
684
    );
685
  }
686

  
687
  function setUp() {
688
    parent::setUp('taxonomy', 'uuid', 'entity', 'features');
689
  }
690
}
drupal7/sites/all/modules/uuid/uuid.tokens.inc
29 29
}
30 30

  
31 31
/**
32
 * Implements hook_token_info_alter()
32
 * Implements hook_token_info_alter().
33 33
 */
34 34
function uuid_token_info_alter(&$data) {
35 35
  foreach (entity_get_info() as $entity_type => $info) {
drupal7/sites/all/modules/uuid/uuid_default_entities_example/uuid_default_entities_example.features.uuid_entities.inc
1
<?php
2
/**
3
 * @file
4
 * uuid_default_entities_example.features.uuid_entities.inc
5
 */
6

  
7
/**
8
 * Implements hook_uuid_default_entities().
9
 */
10
function uuid_default_entities_example_uuid_default_entities() {
11
  $entities = array();
12

  
13
  $entities['deploy_example_plan'][] = (object) array(
14
    '__metadata' => array(
15
      'type' => 'taxonomy_term',
16
      'uri' => 'taxonomy_term/bcb92ce8-2236-e264-65c8-0c163ae716d1',
17
      'cause' => 'node/b0558664-c94b-3674-d9df-3e1696b2e471',
18
    ),
19
    'description' => NULL,
20
    'format' => NULL,
21
    'name' => 'Foo',
22
    'path' => array(
23
      'alias' => 'term/foo',
24
    ),
25
    'rdf_mapping' => array(
26
      'rdftype' => array(
27
        0 => 'skos:Concept',
28
      ),
29
      'name' => array(
30
        'predicates' => array(
31
          0 => 'rdfs:label',
32
          1 => 'skos:prefLabel',
33
        ),
34
      ),
35
      'description' => array(
36
        'predicates' => array(
37
          0 => 'skos:definition',
38
        ),
39
      ),
40
      'vid' => array(
41
        'predicates' => array(
42
          0 => 'skos:inScheme',
43
        ),
44
        'type' => 'rel',
45
      ),
46
      'parent' => array(
47
        'predicates' => array(
48
          0 => 'skos:broader',
49
        ),
50
        'type' => 'rel',
51
      ),
52
    ),
53
    'uuid' => 'bcb92ce8-2236-e264-65c8-0c163ae716d1',
54
    'vocabulary_machine_name' => 'tags',
55
    'weight' => '0',
56
  );
57
  $entities['deploy_example_plan'][] = (object) array(
58
    '__metadata' => array(
59
      'type' => 'taxonomy_term',
60
      'uri' => 'taxonomy_term/4293a15c-531a-6164-7d1b-668ed019a6bd',
61
      'cause' => 'node/b0558664-c94b-3674-d9df-3e1696b2e471',
62
    ),
63
    'description' => NULL,
64
    'format' => NULL,
65
    'name' => 'Bar',
66
    'rdf_mapping' => array(
67
      'rdftype' => array(
68
        0 => 'skos:Concept',
69
      ),
70
      'name' => array(
71
        'predicates' => array(
72
          0 => 'rdfs:label',
73
          1 => 'skos:prefLabel',
74
        ),
75
      ),
76
      'description' => array(
77
        'predicates' => array(
78
          0 => 'skos:definition',
79
        ),
80
      ),
81
      'vid' => array(
82
        'predicates' => array(
83
          0 => 'skos:inScheme',
84
        ),
85
        'type' => 'rel',
86
      ),
87
      'parent' => array(
88
        'predicates' => array(
89
          0 => 'skos:broader',
90
        ),
91
        'type' => 'rel',
92
      ),
93
    ),
94
    'uuid' => '4293a15c-531a-6164-7d1b-668ed019a6bd',
95
    'vocabulary_machine_name' => 'tags',
96
    'weight' => '0',
97
  );
98
  $entities['deploy_example_plan'][] = (object) array(
99
    '__metadata' => array(
100
      'type' => 'node',
101
      'uri' => 'node/b0558664-c94b-3674-d9df-3e1696b2e471',
102
      'cause' => FALSE,
103
    ),
104
    'body' => array(
105
      'und' => array(
106
        0 => array(
107
          'format' => 'filtered_html',
108
          'summary' => '',
109
          'value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
110
        ),
111
      ),
112
    ),
113
    'cid' => '0',
114
    'comment' => '2',
115
    'comment_count' => '0',
116
    'field_image' => array(),
117
    'field_tags' => array(
118
      'und' => array(
119
        0 => array(
120
          'tid' => 'bcb92ce8-2236-e264-65c8-0c163ae716d1',
121
        ),
122
        1 => array(
123
          'tid' => '4293a15c-531a-6164-7d1b-668ed019a6bd',
124
        ),
125
      ),
126
    ),
127
    'language' => 'und',
128
    'last_comment_name' => NULL,
129
    'last_comment_uid' => '1',
130
    'log' => '',
131
    'path' => array(
132
      'alias' => 'lorem-ipsum',
133
    ),
134
    'promote' => '1',
135
    'rdf_mapping' => array(
136
      'field_image' => array(
137
        'predicates' => array(
138
          0 => 'og:image',
139
          1 => 'rdfs:seeAlso',
140
        ),
141
        'type' => 'rel',
142
      ),
143
      'field_tags' => array(
144
        'predicates' => array(
145
          0 => 'dc:subject',
146
        ),
147
        'type' => 'rel',
148
      ),
149
      'rdftype' => array(
150
        0 => 'sioc:Item',
151
        1 => 'foaf:Document',
152
      ),
153
      'title' => array(
154
        'predicates' => array(
155
          0 => 'dc:title',
156
        ),
157
      ),
158
      'created' => array(
159
        'predicates' => array(
160
          0 => 'dc:date',
161
          1 => 'dc:created',
162
        ),
163
        'datatype' => 'xsd:dateTime',
164
        'callback' => 'date_iso8601',
165
      ),
166
      'changed' => array(
167
        'predicates' => array(
168
          0 => 'dc:modified',
169
        ),
170
        'datatype' => 'xsd:dateTime',
171
        'callback' => 'date_iso8601',
172
      ),
173
      'body' => array(
174
        'predicates' => array(
175
          0 => 'content:encoded',
176
        ),
177
      ),
178
      'uid' => array(
179
        'predicates' => array(
180
          0 => 'sioc:has_creator',
181
        ),
182
        'type' => 'rel',
183
      ),
184
      'name' => array(
185
        'predicates' => array(
186
          0 => 'foaf:name',
187
        ),
188
      ),
189
      'comment_count' => array(
190
        'predicates' => array(
191
          0 => 'sioc:num_replies',
192
        ),
193
        'datatype' => 'xsd:integer',
194
      ),
195
      'last_activity' => array(
196
        'predicates' => array(
197
          0 => 'sioc:last_activity_date',
198
        ),
199
        'datatype' => 'xsd:dateTime',
200
        'callback' => 'date_iso8601',
201
      ),
202
    ),
203
    'status' => '1',
204
    'sticky' => '0',
205
    'title' => 'Lorem ipsum',
206
    'tnid' => '0',
207
    'translate' => '0',
208
    'type' => 'article',
209
    'uid' => '1',
210
    'uuid' => 'b0558664-c94b-3674-d9df-3e1696b2e471',
211
  );
212
  $entities['deploy_example_plan'][] = (object) array(
213
    '__metadata' => array(
214
      'type' => 'taxonomy_term',
215
      'uri' => 'taxonomy_term/af738a46-f278-cf84-d94d-9e03879fd71e',
216
      'cause' => 'node/5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837',
217
    ),
218
    'description' => NULL,
219
    'format' => NULL,
220
    'name' => 'Baz',
221
    'rdf_mapping' => array(
222
      'rdftype' => array(
223
        0 => 'skos:Concept',
224
      ),
225
      'name' => array(
226
        'predicates' => array(
227
          0 => 'rdfs:label',
228
          1 => 'skos:prefLabel',
229
        ),
230
      ),
231
      'description' => array(
232
        'predicates' => array(
233
          0 => 'skos:definition',
234
        ),
235
      ),
236
      'vid' => array(
237
        'predicates' => array(
238
          0 => 'skos:inScheme',
239
        ),
240
        'type' => 'rel',
241
      ),
242
      'parent' => array(
243
        'predicates' => array(
244
          0 => 'skos:broader',
245
        ),
246
        'type' => 'rel',
247
      ),
248
    ),
249
    'uuid' => 'af738a46-f278-cf84-d94d-9e03879fd71e',
250
    'vocabulary_machine_name' => 'tags',
251
    'weight' => '0',
252
  );
253
  $entities['deploy_example_plan'][] = (object) array(
254
    '__metadata' => array(
255
      'type' => 'user',
256
      'uri' => 'user/7cf875e6-dc15-4404-f190-5a7c3e91d14c',
257
      'cause' => 'node/5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837',
258
    ),
259
    'init' => 'no@example.com',
260
    'language' => '',
261
    'mail' => 'no@example.com',
262
    'name' => 'mohamed',
263
    'pass' => '$S$DtyVr4YQkvCpofZdLT4.L23Xb6E8HUkmEgZikN919RTZXZSePwso',
264
    'picture' => NULL,
265
    'rdf_mapping' => array(
266
      'rdftype' => array(
267
        0 => 'sioc:UserAccount',
268
      ),
269
      'name' => array(
270
        'predicates' => array(
271
          0 => 'foaf:name',
272
        ),
273
      ),
274
      'homepage' => array(
275
        'predicates' => array(
276
          0 => 'foaf:page',
277
        ),
278
        'type' => 'rel',
279
      ),
280
    ),
281
    'roles' => array(
282
      2 => 'authenticated user',
283
      3 => 'administrator',
284
    ),
285
    'signature' => '',
286
    'signature_format' => 'filtered_html',
287
    'status' => '1',
288
    'theme' => '',
289
    'timezone' => 'Asia/Riyadh',
290
    'uuid' => '7cf875e6-dc15-4404-f190-5a7c3e91d14c',
291
  );
292
  $entities['deploy_example_plan'][] = (object) array(
293
    '__metadata' => array(
294
      'type' => 'node',
295
      'uri' => 'node/5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837',
296
      'cause' => FALSE,
297
    ),
298
    'body' => array(
299
      'und' => array(
300
        0 => array(
301
          'format' => 'filtered_html',
302
          'summary' => '',
303
          'value' => 'Nunc sollicitudin justo ut augue egestas et varius quam consectetur.',
304
        ),
305
      ),
306
    ),
307
    'cid' => '0',
308
    'comment' => '2',
309
    'comment_count' => '0',
310
    'field_image' => array(),
311
    'field_tags' => array(
312
      'und' => array(
313
        0 => array(
314
          'tid' => 'af738a46-f278-cf84-d94d-9e03879fd71e',
315
        ),
316
      ),
317
    ),
318
    'language' => 'und',
319
    'last_comment_name' => NULL,
320
    'last_comment_uid' => '7cf875e6-dc15-4404-f190-5a7c3e91d14c',
321
    'log' => '',
322
    'promote' => '1',
323
    'rdf_mapping' => array(
324
      'field_image' => array(
325
        'predicates' => array(
326
          0 => 'og:image',
327
          1 => 'rdfs:seeAlso',
328
        ),
329
        'type' => 'rel',
330
      ),
331
      'field_tags' => array(
332
        'predicates' => array(
333
          0 => 'dc:subject',
334
        ),
335
        'type' => 'rel',
336
      ),
337
      'rdftype' => array(
338
        0 => 'sioc:Item',
339
        1 => 'foaf:Document',
340
      ),
341
      'title' => array(
342
        'predicates' => array(
343
          0 => 'dc:title',
344
        ),
345
      ),
346
      'created' => array(
347
        'predicates' => array(
348
          0 => 'dc:date',
349
          1 => 'dc:created',
350
        ),
351
        'datatype' => 'xsd:dateTime',
352
        'callback' => 'date_iso8601',
353
      ),
354
      'changed' => array(
355
        'predicates' => array(
356
          0 => 'dc:modified',
357
        ),
358
        'datatype' => 'xsd:dateTime',
359
        'callback' => 'date_iso8601',
360
      ),
361
      'body' => array(
362
        'predicates' => array(
363
          0 => 'content:encoded',
364
        ),
365
      ),
366
      'uid' => array(
367
        'predicates' => array(
368
          0 => 'sioc:has_creator',
369
        ),
370
        'type' => 'rel',
371
      ),
372
      'name' => array(
373
        'predicates' => array(
374
          0 => 'foaf:name',
375
        ),
376
      ),
377
      'comment_count' => array(
378
        'predicates' => array(
379
          0 => 'sioc:num_replies',
380
        ),
381
        'datatype' => 'xsd:integer',
382
      ),
383
      'last_activity' => array(
384
        'predicates' => array(
385
          0 => 'sioc:last_activity_date',
386
        ),
387
        'datatype' => 'xsd:dateTime',
388
        'callback' => 'date_iso8601',
389
      ),
390
    ),
391
    'status' => '1',
392
    'sticky' => '0',
393
    'title' => 'Nunc sollicitudin',
394
    'tnid' => '0',
395
    'translate' => '0',
396
    'type' => 'article',
397
    'uid' => '7cf875e6-dc15-4404-f190-5a7c3e91d14c',
398
    'uuid' => '5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837',
399
  );
400

  
401
  return $entities;
402
}
drupal7/sites/all/modules/uuid/uuid_default_entities_example/uuid_default_entities_example.info
1
core = "7.x"
2
dependencies[] = "entity"
3
dependencies[] = "features"
4
dependencies[] = "uuid"
5
description = "Example feature mainly used for testing."
6
features[uuid_entities][] = "deploy_example_plan"
7
name = "UUID default entities example"
8
package = "Features"
9

  
10
; Information added by drupal.org packaging script on 2013-07-12
11
version = "7.x-1.0-alpha5"
12
core = "7.x"
13
project = "uuid"
14
datestamp = "1373620283"
15

  
drupal7/sites/all/modules/uuid/uuid_default_entities_example/uuid_default_entities_example.module
1
<?php
2
/**
3
 * @file
4
 */
5

  
6
// Drupal needs this blank file.
drupal7/sites/all/modules/uuid/uuid_path/uuid_path.info
5 5
dependencies[] = uuid
6 6

  
7 7

  
8
; Information added by drupal.org packaging script on 2013-07-12
9
version = "7.x-1.0-alpha5"
8
; Information added by Drupal.org packaging script on 2014-09-23
9
version = "7.x-1.0-alpha6"
10 10
core = "7.x"
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff