8.x version of votingapi_set_votes

Created on 1 September 2023, 10 months ago

Problem/Motivation

Apologies if this is a basic question, but I'm updating a D7 module that utlized this API to a D9 version and I'm struggling to understand how to use the 8.x version of this module.

In the D7 version there was the votingapi_set_votes hook we could use to submit votes. It appears this no longer exists in 8.x, though in the API.txt is says: "The simplest modules only need to call two functions -- votingapi_set_vote() and votingapi_select_results() -- to use the API."

Is there a new way to send and submit votes using hooks in the 8.x version?

πŸ’¬ Support request
Status

Active

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States mscipioni

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mscipioni
  • πŸ‡ΊπŸ‡ΈUnited States mscipioni
  • πŸ‡ΊπŸ‡ΈUnited States TR Cascadia

    I don't think there is an exact replacement. I wasn't involved in the D7 version of this module or in the port, but it looks like in D7 the votes were stored in a custom table and now in D8+ votes are stored as entities. votingapi_set_votes() in D7 looks like it does bulk operations to insert/update/delete multiple votes from the database in one operation. But there is no corresponding way to insert/update/delete entities in bulk in D8+.

    I don't know if this change is documented anywhere - it looks like the D7 code was just replaced by a privately developed D8 version without discussion, so it's not clear to me what architectural changes were made and why, and it's not clear to me what functionality was lost (intentionally or otherwise), replaced, or added.

    It *is* clear to me that in the port we lost a lot of documentation on how to use this module. If someone has current documentation or is willing to write improved documentation we would all appreciate the help.

    As far as porting your code goes, I would look at _votingapi_cast_votes() found in votingapi.devel.inc in the D7 version and castVotes() found in src/Commands/VotingApiCommand.php in the D8+ version. Those functions do the exact same thing, so I think this makes it clear how to achieve the "set votes" functionality in D8+.

Production build 0.69.0 2024