mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 03:02:43 +01:00
9be755ab12
Summary: Ref T603. Ref T2625. Start pushing Slowvote (the greatest app of all time) into the modern era. Test Plan: Looked at vote detail. Used `V1` and `{V1}` embeds. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T603, T2625 Differential Revision: https://secure.phabricator.com/D6444
43 lines
1 KiB
PHP
43 lines
1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group slowvote
|
|
*/
|
|
final class SlowvoteRemarkupRule
|
|
extends PhabricatorRemarkupRuleObject {
|
|
|
|
protected function getObjectNamePrefix() {
|
|
return 'V';
|
|
}
|
|
|
|
protected function loadObjects(array $ids) {
|
|
$viewer = $this->getEngine()->getConfig('viewer');
|
|
|
|
return id(new PhabricatorSlowvoteQuery())
|
|
->setViewer($viewer)
|
|
->withIDs($ids)
|
|
->execute();
|
|
}
|
|
|
|
protected function renderObjectEmbed($object, $handle, $options) {
|
|
$viewer = $this->getEngine()->getConfig('viewer');
|
|
|
|
$options = id(new PhabricatorSlowvoteOption())->loadAllWhere(
|
|
'pollID = %d',
|
|
$object->getID());
|
|
$choices = id(new PhabricatorSlowvoteChoice())->loadAllWhere(
|
|
'pollID = %d',
|
|
$object->getID());
|
|
$choices_by_user = mgroup($choices, 'getAuthorPHID');
|
|
|
|
$viewer_choices = idx($choices_by_user, $viewer->getPHID(), array());
|
|
|
|
$embed = id(new SlowvoteEmbedView())
|
|
->setPoll($object)
|
|
->setOptions($options)
|
|
->setViewerChoices($viewer_choices);
|
|
|
|
return $embed->render();
|
|
}
|
|
|
|
}
|