Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently Measured Value Field doesn't support EntityMetadataWrapper. It would be really nice to have an ability to use this field in wrapper.
How to reproduce:
Add mvf field to the node, check available wrapper properties:
$node = node_load(1);
$wrapper = entity_metadata_wrapper('node', $node);
dsm($wrapper->getPropertyInfo());
added mvf field not available for using.
Comment | File | Size | Author |
---|---|---|---|
#14 | 2405779-metadata-wrappers-12.patch | 1.8 KB | bucefal91 |
#11 | 2405779-metadata-wrappers-11.patch | 4.07 KB | bucefal91 |
#11 | 2405779-interdiff-11.patch | 3.43 KB | bucefal91 |
#10 | 2405779-metadata-wrappers-10.patch | 1.66 KB | bucefal91 |
#10 | 2405779-interdiff-10.patch | 617 bytes | bucefal91 |
Comments
Comment #1
skorzhMy patch fixed it.
Now you can work with mvf field in wrapper.
Some examples:
Comment #2
AndrewsizZ CreditAttribution: AndrewsizZ commentedNice, tested on ERPAL, works like a charm!
Comment #3
SpleshkaFor me it also looks good, thanks for this patch.
Comment #4
skorzhNo updates here?
Comment #5
skorzhStill no updates here?
Comment #6
SpleshkaWell, I would also like to see this patch commited.
Comment #7
Greg Varga CreditAttribution: Greg Varga commented#1 works perfectly.
Additional info on setting units and values:
Comment #8
skorzhStill no updates here?
Comment #9
skorzhMore then one year no any response from maintainers, maybe it make sense to at least change status from 'Actively maintained' and don't confuse people?
Comment #10
bucefal91 CreditAttribution: bucefal91 commentedHello!
This is me, whom you are blaming. And you do so rightly. I dedicate to this module less time than I would like to. I maintain other 3 modules on d.org and this one has the least popularity, so I feel obliged to give it only a fraction of my time. But I am willing to sort this issue.
Thank you for the patch. I've reviewed it - you got most of it done. The only suggestion I could come up with is that it would be great to also include into the wrapper API ability to fetch MVF value in a specific unit. Right now using the patch we can fetch both absolute value and the unit that corresponds to that value, but we're basically forced to do the conversion in client code, which is not that nice.
So, let's get one more feature:
Or it could be:
I've tried to implement this addition tonight, but entity API wrappers abstractions are definitely way too baked for my brain after midnight. I'll get it tomorrow.
In the mean time I only edited 2 lines of code: strictly speaking both 'value' and 'unit' need 'schema field' and we map from 'value' and 'unit' properties to specific columns through mvf_subfield_to_column() function.
Comment #11
bucefal91 CreditAttribution: bucefal91 commentedI am glad I heard the voice of rationalism in my head and put it off yesterday. No way I would have gotten it done last night. After poking entity API module seems like the best option I can get is:
So it takes the form of
Apart from it nothing is changed. I enclose the 2 patches: against current 7.x-1.x and interdiff against korgik's contribution. Let's see if you like it?
Comment #12
skorzhSorry, did't want to blaming you :) Just wanted to pay your attention on forgotten issue.
I've tested your patch, works good for me, its definitely a good feature to get converted value, but maybe we have to documented it somewhere since its not obvious how to use it?
Comment #14
bucefal91 CreditAttribution: bucefal91 commentedGood point. I've added our PHP snippets from this issue into README.txt (patch enclosed). I also have a rule of thumb of not publishing stable release of any module without up-to-date existing documentation page. So, when MVF gets stable for 7.x-1.0 release, I'll include this info into its documentation page too.
Comment #15
skorzhGreat, thanks!
Comment #17
elpino CreditAttribution: elpino as a volunteer commentedIs is possible to get the converted value's unit label or symbol?
Comment #18
bucefal91 CreditAttribution: bucefal91 commentedNot really, since you are the one who dictated into what unit to covert, it is assumed you already know its label or unit or anything else about the target unit. I'd do something like the following (load the unit, so later on we can fetch its label, and get MVF converted into it):