Changeset View
Changeset View
Standalone View
Standalone View
src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
Show All 14 Lines | final class PhabricatorSlowvotePoll | ||||
protected $question; | protected $question; | ||||
protected $description; | protected $description; | ||||
protected $authorPHID; | protected $authorPHID; | ||||
protected $responseVisibility; | protected $responseVisibility; | ||||
protected $shuffle = 0; | protected $shuffle = 0; | ||||
protected $method; | protected $method; | ||||
protected $viewPolicy; | protected $viewPolicy; | ||||
protected $isClosed = 0; | protected $isClosed; | ||||
protected $spacePHID; | protected $spacePHID; | ||||
private $options = self::ATTACHABLE; | private $options = self::ATTACHABLE; | ||||
private $choices = self::ATTACHABLE; | private $choices = self::ATTACHABLE; | ||||
private $viewerChoices = self::ATTACHABLE; | private $viewerChoices = self::ATTACHABLE; | ||||
public static function initializeNewPoll(PhabricatorUser $actor) { | public static function initializeNewPoll(PhabricatorUser $actor) { | ||||
$app = id(new PhabricatorApplicationQuery()) | $app = id(new PhabricatorApplicationQuery()) | ||||
->setViewer($actor) | ->setViewer($actor) | ||||
->withClasses(array('PhabricatorSlowvoteApplication')) | ->withClasses(array('PhabricatorSlowvoteApplication')) | ||||
->executeOne(); | ->executeOne(); | ||||
$view_policy = $app->getPolicy( | $view_policy = $app->getPolicy( | ||||
PhabricatorSlowvoteDefaultViewCapability::CAPABILITY); | PhabricatorSlowvoteDefaultViewCapability::CAPABILITY); | ||||
$default_responses = SlowvotePollResponseVisibility::RESPONSES_VISIBLE; | $default_responses = SlowvotePollResponseVisibility::RESPONSES_VISIBLE; | ||||
$default_method = SlowvotePollVotingMethod::METHOD_PLURALITY; | $default_method = SlowvotePollVotingMethod::METHOD_PLURALITY; | ||||
return id(new PhabricatorSlowvotePoll()) | return id(new PhabricatorSlowvotePoll()) | ||||
->setAuthorPHID($actor->getPHID()) | ->setAuthorPHID($actor->getPHID()) | ||||
->setViewPolicy($view_policy) | ->setViewPolicy($view_policy) | ||||
->setSpacePHID($actor->getDefaultSpacePHID()) | ->setSpacePHID($actor->getDefaultSpacePHID()) | ||||
->setIsClosed(SlowvotePollStatus::STATUS_OPEN) | |||||
->setMethod($default_method) | ->setMethod($default_method) | ||||
->setResponseVisibility($default_responses); | ->setResponseVisibility($default_responses); | ||||
} | } | ||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'question' => 'text255', | 'question' => 'text255', | ||||
'responseVisibility' => 'text32', | 'responseVisibility' => 'text32', | ||||
'shuffle' => 'bool', | 'shuffle' => 'bool', | ||||
'method' => 'text32', | 'method' => 'text32', | ||||
'description' => 'text', | 'description' => 'text', | ||||
'isClosed' => 'bool', | 'isClosed' => 'bool', | ||||
), | ), | ||||
self::CONFIG_KEY_SCHEMA => array( | self::CONFIG_KEY_SCHEMA => array( | ||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function getPHIDType() { | public function getPHIDType() { | ||||
return PhabricatorSlowvotePollPHIDType::TYPECONST; | return PhabricatorSlowvotePollPHIDType::TYPECONST; | ||||
} | } | ||||
public function getStatusObject() { | |||||
return SlowvotePollStatus::newStatusObject($this->getIsClosed()); | |||||
} | |||||
public function isClosed() { | |||||
return ($this->getIsClosed() == SlowvotePollStatus::STATUS_CLOSED); | |||||
} | |||||
public function getOptions() { | public function getOptions() { | ||||
return $this->assertAttached($this->options); | return $this->assertAttached($this->options); | ||||
} | } | ||||
public function attachOptions(array $options) { | public function attachOptions(array $options) { | ||||
assert_instances_of($options, 'PhabricatorSlowvoteOption'); | assert_instances_of($options, 'PhabricatorSlowvoteOption'); | ||||
$this->options = $options; | $this->options = $options; | ||||
return $this; | return $this; | ||||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |