1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Slowvote - add ability to destroy a poll

Summary: Fixes T5773.

Test Plan: Made a poll and voted on it. Deleted it via ./bin/remove destory V1. No errors and the poll is gone.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5773

Differential Revision: https://secure.phabricator.com/D10167
This commit is contained in:
Bob Trahan 2014-08-06 14:19:37 -07:00
parent 77fa7c8939
commit 50a393913c

View file

@ -6,7 +6,8 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
PhabricatorSubscribableInterface,
PhabricatorFlaggableInterface,
PhabricatorTokenReceiverInterface,
PhabricatorProjectInterface {
PhabricatorProjectInterface,
PhabricatorDestructibleInterface {
const RESPONSES_VISIBLE = 0;
const RESPONSES_VOTERS = 1;
@ -139,4 +140,26 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
return array($this->getAuthorPHID());
}
/* -( PhabricatorDestructableInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$choices = id(new PhabricatorSlowvoteChoice())->loadAllWhere(
'pollID = %d',
$this->getID());
foreach ($choices as $choice) {
$choice->delete();
}
$options = id(new PhabricatorSlowvoteOption())->loadAllWhere(
'pollID = %d',
$this->getID());
foreach ($options as $option) {
$option->delete();
}
$this->delete();
$this->saveTransaction();
}
}