1 vote for 1 person ?
Hello,
Is it possible to allow people vote only if they haven't vote?
How can I do?
Someone is currently working on this, and we expect to have rate limiting features for voting soon.
Thanks merk. So Have a deadline?
At this time there is no deadline. I expect to release 0.9.1 soon with some major changes that will make it easier for features like this to be added. Hopefully within a few days.
Cool thanks
So voting system already works? Is there any doc/example where I can see how to implement it?
Your comment should implement VotableCommentInterface which will enable basic voting, but there is no rate control or validation on voting which you will need to implement yourself.
Cool, I'll look into it. Will you accept PR if I manage to implement it? Thanks.
A small documentation would be great on this feature. I didn't know about this.
Yeah, any documentation or additions are welcome. I dont use voting at the moment, so havent had a chance to do anything with it.
Any update on this? Is there a branch where rate limiting implementation is happening so we can track or help?
Noone has contributed this feature yet, we will accept a pull with this if someone wants to do it
I had thought to create a new event VotePersistEvent, like CommentPersist, modify VoteManager in that way to abort persistence. But I guess this is not an option because of the BC
I want to modify a few sections of FOSCB for a new version that removes a lot of legacy things. I regret tagging 2.0.0, so I'll probably have to go to 3 for these changes.
I dont mind such a PR, except that I'd like the voting API to respond with an error code if the vote is not accepted, instead of just silently failing (or at the very least, an option to configure that).
Does this functionality exist yet? I'm a little confused as this issue is tagged as "Documentation", although by the sound of it the actual feature doesn't seem to have been implemented yet.
Any advances on this?
Could you explain your proposal a bit @franmomu , to see if I can do a temporal implementation for my project?
I suggested to create a new VotePersistEvent, like CommentPersistEvent, so you could create a listener for VOTE_PRE_PERSIST event to abort persistance.
Then in saveVote method of VoteManager the event will be VotePersistEvent and then check if the persistance should be aborted like CommentManager, I don't know why I said about BC, but it's true what @merk said that this will fail silently and you won't be able to know why the vote was not persisted.
So, I think this validation should be done before the saveVote method, one way to do this (I've just tried) is to create a Custom Validation Constraint as a service with class scope and apply to your Vote Entity/Document, you can inject the VoteManager and SecurityContext to the Validator and then (after some checks) do something like this:
$existingVote = $this->voteManager->findVoteBy(array(
'user' => $this->securityContext->getToken()->getUser()->getId(),
'comment' => $vote->getComment()->getId()
));
if ($existingVote) {
$this->context->addViolation($constraint->message);
}
If the example is ok, I can write it in full in the documentation.
Your proposal is good. We'd need to add a VotePersistEvent but I would merge such a pull request.