Created
March 11, 2017 10:44
-
-
Save e0ipso/5a3a9511c0f1af944aca988175cc89c1 to your computer and use it in GitHub Desktop.
Allow setting the UUID from the front-end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_entity_property_info_alter(). | |
*/ | |
function mymodule_entity_property_info_alter(&$info) { | |
// Add the uuid setter if not present. | |
foreach (entity_get_info() as $entity_type => $entity_info) { | |
if ( | |
!empty($entity_info['uuid']) | |
&& !empty($entity_info['entity keys']['uuid']) | |
&& !empty($info[$entity_type]['properties'][$entity_info['entity keys']['uuid']]) | |
) { | |
// This entity type supports a UUID. | |
$uuid_info = &$info[$entity_type]['properties'][$entity_info['entity keys']['uuid']]; | |
$uuid_info['setter callback'] = 'entity_property_verbatim_set'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment