How to get instance of Module / Plugin / Widget of Vote Object in THEME_preprocess_node? My drupal site is using the Fivestar Module or from the Vote Up Down Module.
Multiple of my content types are using various implementations of these as fields (specifically comments and my primary articles. Users can up/downvote comments and articles, and also give them ratings).
In my theme, I want to be able to access things like the vote count, and if the current user has voted, and ideally even the vote and reset links for custom display and front end functionality.
The default way how things are displayed doesn't work for my purposes, and creating specific views/blocks for each little snippet on my page, or manually overriding each template seems too cumbersome, and not flexible enough.
I'd much rather get all the vote info that I need in an array and pass it to my template, to be then displayed for full nodes, teasers, and comments.
How can I make use of the pre-formatted data that the modules are fetching and compiling from the database?
I see for example that abstract class VoteUpDownWidgetBase extends PluginBase implements VoteUpDownWidgetInterface has a method public function build($entity) which does exactly what I need to do. It gets all of the data about the vote field, and formats it for display in a template.
I don't see this equivalent from the Fivestar Module yet, but I'm sure I'll find something useful...
Either way: How can I access this method? What class do I have to get an instance of?
Turns out, everything I need is in $variables['content'] as long as the widgets/plugins that I'm trying to display are set to display as part of the view mode.
So in my specific case I can for example access $variables['content']['field_upvotes']['#up_points'] and that contains the number of upvotes!
Easy enough! :-)