diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 962a6d4725..ae6c5383ee 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1698,6 +1698,7 @@ phutil_register_library_map(array( 'PhabricatorTokenGivenFeedStory' => 'applications/tokens/feed/PhabricatorTokenGivenFeedStory.php', 'PhabricatorTokenGivenQuery' => 'applications/tokens/query/PhabricatorTokenGivenQuery.php', 'PhabricatorTokenLeaderController' => 'applications/tokens/controller/PhabricatorTokenLeaderController.php', + 'PhabricatorTokenPHIDTypeToken' => 'applications/tokens/phid/PhabricatorTokenPHIDTypeToken.php', 'PhabricatorTokenQuery' => 'applications/tokens/query/PhabricatorTokenQuery.php', 'PhabricatorTokenReceiverInterface' => 'applications/tokens/interface/PhabricatorTokenReceiverInterface.php', 'PhabricatorTokenReceiverQuery' => 'applications/tokens/query/PhabricatorTokenReceiverQuery.php', @@ -3856,6 +3857,7 @@ phutil_register_library_map(array( 'PhabricatorTokenGivenFeedStory' => 'PhabricatorFeedStory', 'PhabricatorTokenGivenQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorTokenLeaderController' => 'PhabricatorTokenController', + 'PhabricatorTokenPHIDTypeToken' => 'PhabricatorPHIDType', 'PhabricatorTokenQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorTokenReceiverQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorTokenUIEventListener' => 'PhutilEventListener', diff --git a/src/applications/tokens/feed/PhabricatorTokenGivenFeedStory.php b/src/applications/tokens/feed/PhabricatorTokenGivenFeedStory.php index 3fd1daf195..d448f0b989 100644 --- a/src/applications/tokens/feed/PhabricatorTokenGivenFeedStory.php +++ b/src/applications/tokens/feed/PhabricatorTokenGivenFeedStory.php @@ -14,6 +14,12 @@ final class PhabricatorTokenGivenFeedStory return $phids; } + public function getRequiredObjectPHIDs() { + $phids = array(); + $phids[] = $this->getValue('tokenPHID'); + return $phids; + } + public function renderView() { $view = $this->newStoryView(); $view->setAppIcon('token-dark'); @@ -22,10 +28,13 @@ final class PhabricatorTokenGivenFeedStory $href = $this->getHandle($this->getPrimaryObjectPHID())->getURI(); $view->setHref($href); + $token = $this->getObject($this->getValue('tokenPHID')); + $title = pht( - '%s awarded %s a token.', + '%s awarded %s a %s token.', $this->linkTo($this->getValue('authorPHID')), - $this->linkTo($this->getValue('objectPHID'))); + $this->linkTo($this->getValue('objectPHID')), + $token->getName()); $view->setTitle($title); $view->setImage($this->getHandle($author_phid)->getImageURI()); diff --git a/src/applications/tokens/phid/PhabricatorTokenPHIDTypeToken.php b/src/applications/tokens/phid/PhabricatorTokenPHIDTypeToken.php new file mode 100644 index 0000000000..7d0a1f69a6 --- /dev/null +++ b/src/applications/tokens/phid/PhabricatorTokenPHIDTypeToken.php @@ -0,0 +1,44 @@ +setViewer($query->getViewer()) + ->setParentQuery($query) + ->withPHIDs($phids) + ->execute(); + } + + public function loadHandles( + PhabricatorHandleQuery $query, + array $handles, + array $objects) { + + foreach ($handles as $phid => $handle) { + $token = $objects[$phid]; + + $name = $token->getName(); + + $handle->setName("{$name} Token"); + } + } + +} diff --git a/src/applications/tokens/query/PhabricatorTokenQuery.php b/src/applications/tokens/query/PhabricatorTokenQuery.php index 8fa36f8803..c4bf4a975b 100644 --- a/src/applications/tokens/query/PhabricatorTokenQuery.php +++ b/src/applications/tokens/query/PhabricatorTokenQuery.php @@ -45,6 +45,8 @@ final class PhabricatorTokenQuery array('misc-4', pht('The World Burns')), ); + $type = PhabricatorTokenPHIDTypeToken::TYPECONST; + $tokens = array(); foreach ($specs as $id => $spec) { list($image, $name) = $spec; @@ -52,7 +54,7 @@ final class PhabricatorTokenQuery $token = id(new PhabricatorToken()) ->setID($id) ->setName($name) - ->setPHID('PHID-TOKN-'.$image); + ->setPHID('PHID-'.$type.'-'.$image); $tokens[] = $token; }