Active
Project:
Entity API
Version:
7.x-1.x-dev
Component:
Entity property wrapper
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
4 Feb 2012 at 03:13 UTC
Updated:
10 Jun 2017 at 10:09 UTC
Jump to comment: Most recent
Comments
Comment #1
danielnolde commentedThere seems to be some error or misunderstanding in one of Yuri's code examples:
This actually doesn't get the entity's "authors" 's roles, but a list of all values applicable to the roles property (i.e. _all_ roles defined in the system, not given to that user!). The correct statement for the purpose stated in the comment would be:
Sadly, this then gets only an array of the role's RIDs, and not an associative array in the form of RID=>rolename as we'd get from a simple $user->roles - sometimes using EntityMetadataWrapper makes life more complex instead of simpler... <;)
Comment #2
prabhatjn commentedWhat could be a good way to read $wrapper.
dsm does not work so good here.
P.
Comment #3
joachim commented$wrapper's properties are protected so dsm() doesn't see them.
You can temporarily hack some of those to be public if you're debugging.
But most of the stuff you might be interested in is lazy loaded, so won't be there anyway.
What's useful to dsm though is $wrapper->getPropertyInfo() which shows you all the properties on the wrapper.
Comment #4
antonio_pantano commentedI think it will not give you the translated body text.
As far as I know, Drupal creates 2 versions of the node. The first one is the original, say in English, and has a nod id, say 100. The translated version has its own node id, lets suppose 200 (a distinct node) , so when you load the node with the id 100 you are wrapping the english node, so calling $wrapper->language('de')->body->summary->value() will still result in the original (English) node and no translated version will be available since the german node has the nid 200. To work on it you have to use $wrapper_de = entity_metadata_wrapper('node', [nid of the german node]);
Comment #5
Rahul2386 commentedHello
I am working on above code but I am unable to save $wrapper I am getting exception as below
exception 'Exception' with message 'The host entity cannot be changed.' in /mnt/www/html/konecranesdev/docroot/sites/all/modules/contrib/field_collection/field_collection.module:359 Stack trace: #0 /mnt/www/html/konecranesdev/docroot/sites/all/modules/contrib/field_collection/field_collection.module(1031): FieldCollectionItemEntity->updateHostEntity(Object(stdClass)) #1 /mnt/www/html/konecranesdev/docroot/modules/field/field.attach.inc(209): field_collection_field_update('node', Object(stdClass), Array, Array, 'und', Array, NULL, NULL)
Comment #6
sandboxplWhat about adding a link to documentation page in README.txt ? A lot of examples can be found here:
https://www.drupal.org/docs/7/api/entity-api/entity-metadata-wrappers