Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / tokens / query / PhabricatorTokenQuery.php
blob07e15d4b0348e469f986f56bd9f61374755b6fcf
1 <?php
3 final class PhabricatorTokenQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery {
6 private $phids;
8 public function withPHIDs(array $phids) {
9 $this->phids = $phids;
10 return $this;
13 protected function loadPage() {
14 $tokens = $this->getBuiltinTokens();
16 if ($this->phids) {
17 $map = array_fill_keys($this->phids, true);
18 foreach ($tokens as $key => $token) {
19 if (empty($map[$token->getPHID()])) {
20 unset($tokens[$key]);
25 return $tokens;
28 private function getBuiltinTokens() {
29 $specs = array(
30 array('like-1', pht('Like')),
31 array('like-2', pht('Dislike')),
32 array('heart-1', pht('Love')),
33 array('heart-2', pht('Heartbreak')),
34 array('medal-1', pht('Orange Medal')),
35 array('medal-2', pht('Grey Medal')),
36 array('medal-3', pht('Yellow Medal')),
37 array('medal-4', pht('Manufacturing Defect?')),
38 array('coin-1', pht('Haypence')),
39 array('coin-2', pht('Piece of Eight')),
40 array('coin-3', pht('Doubloon')),
41 array('coin-4', pht('Mountain of Wealth')),
42 array('misc-1', pht('Pterodactyl')),
43 array('misc-2', pht('Evil Spooky Haunted Tree')),
44 array('misc-3', pht('Baby Tequila')),
45 array('misc-4', pht('The World Burns')),
46 array('emoji-1', pht('100')),
47 array('emoji-2', pht('Party Time')),
48 array('emoji-3', pht('Y So Serious')),
49 array('emoji-4', pht('Dat Boi')),
50 array('emoji-5', pht('Cup of Joe')),
51 array('emoji-6', pht('Hungry Hippo')),
52 array('emoji-7', pht('Burninate')),
53 array('emoji-8', pht('Pirate Logo')),
56 $type = PhabricatorTokenTokenPHIDType::TYPECONST;
58 $tokens = array();
59 foreach ($specs as $id => $spec) {
60 list($image, $name) = $spec;
62 $token = id(new PhabricatorToken())
63 ->setID($id)
64 ->setName($name)
65 ->setPHID('PHID-'.$type.'-'.$image);
66 $tokens[] = $token;
69 return $tokens;
73 public function getQueryApplicationClass() {
74 return 'PhabricatorTokensApplication';