1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 11:12:42 +01:00
phorge-phorge/src/applications/slowvote/remarkup/SlowvoteRemarkupRule.php

44 lines
1 KiB
PHP
Raw Normal View History

<?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();
}
}