Commit f930e282 authored by Devin Carlson's avatar Devin Carlson

Improved UUID support.

parent 8c4e0dad
......@@ -96,7 +96,7 @@ function entity_embed_dialog_form($form, &$form_state, $input, $filter_format, $
}
$default = '';
if (!empty($entity_element['data-entity-uuid'])) {
if (!empty($entity_element['data-entity-uuid']) && module_exists('uuid')) {
$entity = entity_uuid_load($entity_element['data-entity-type'], array($entity_element['data-entity-uuid']));
$entity = reset($entity);
}
......@@ -150,7 +150,7 @@ function entity_embed_dialog_form($form, &$form_state, $input, $filter_format, $
case 'embed':
$form['#title'] = t('Edit embedded entity');
if (!empty($entity_element['data-entity-uuid'])) {
if (!empty($entity_element['data-entity-uuid']) && module_exists('uuid')) {
$entity = entity_uuid_load($entity_element['data-entity-type'], array($entity_element['data-entity-uuid']));
$entity = reset($entity);
}
......
......@@ -406,7 +406,7 @@ function _entity_embed_render_placeholders($text) {
$uuid = $node->getAttribute('data-entity-uuid');
$id = $node->getAttribute('data-entity-id');
if (!empty($uuid)) {
if (!empty($uuid) && module_exists('uuid')) {
$entity = entity_uuid_load($entity_type, array($uuid));
$entity = reset($entity);
}
......
......@@ -165,9 +165,18 @@ function entity_embed_filter_parse_from_fields($entity_type, $entity) {
$xpath = new \DOMXPath($dom);
foreach ($xpath->query('//*[@data-entity-type="file" and (@data-entity-uuid or @data-entity-id)]') as $node) {
$id = $node->getAttribute('data-entity-uuid') ?: $node->getAttribute('data-entity-id');
$fids[] = $id;
$uuid = $node->getAttribute('data-entity-uuid');
$id = $node->getAttribute('data-entity-id');
if (!empty($uuid) && module_exists('uuid')) {
$ids = entity_get_id_by_uuid('file', array($uuid));
$fid = reset($ids);
}
else {
$fid = $id;
}
$fids[] = $fid;
}
}
}
......
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