1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 10:42:41 +01:00

Use application PHIDs for Diviner Books

Summary: Ref T2715.

Test Plan: `phid.query`

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2715

Differential Revision: https://secure.phabricator.com/D6596
This commit is contained in:
epriestley 2013-07-30 06:47:07 -07:00
parent 8e1dd430fd
commit bdc93f65a2
4 changed files with 48 additions and 2 deletions

View file

@ -533,6 +533,7 @@ phutil_register_library_map(array(
'DivinerLiveBook' => 'applications/diviner/storage/DivinerLiveBook.php', 'DivinerLiveBook' => 'applications/diviner/storage/DivinerLiveBook.php',
'DivinerLivePublisher' => 'applications/diviner/publisher/DivinerLivePublisher.php', 'DivinerLivePublisher' => 'applications/diviner/publisher/DivinerLivePublisher.php',
'DivinerLiveSymbol' => 'applications/diviner/storage/DivinerLiveSymbol.php', 'DivinerLiveSymbol' => 'applications/diviner/storage/DivinerLiveSymbol.php',
'DivinerPHIDTypeBook' => 'applications/diviner/phid/DivinerPHIDTypeBook.php',
'DivinerPublishCache' => 'applications/diviner/cache/DivinerPublishCache.php', 'DivinerPublishCache' => 'applications/diviner/cache/DivinerPublishCache.php',
'DivinerPublisher' => 'applications/diviner/publisher/DivinerPublisher.php', 'DivinerPublisher' => 'applications/diviner/publisher/DivinerPublisher.php',
'DivinerRemarkupRuleSymbol' => 'applications/diviner/markup/DivinerRemarkupRuleSymbol.php', 'DivinerRemarkupRuleSymbol' => 'applications/diviner/markup/DivinerRemarkupRuleSymbol.php',
@ -2536,6 +2537,7 @@ phutil_register_library_map(array(
1 => 'PhabricatorPolicyInterface', 1 => 'PhabricatorPolicyInterface',
2 => 'PhabricatorMarkupInterface', 2 => 'PhabricatorMarkupInterface',
), ),
'DivinerPHIDTypeBook' => 'PhabricatorPHIDType',
'DivinerPublishCache' => 'DivinerDiskCache', 'DivinerPublishCache' => 'DivinerDiskCache',
'DivinerRemarkupRuleSymbol' => 'PhutilRemarkupRule', 'DivinerRemarkupRuleSymbol' => 'PhutilRemarkupRule',
'DivinerStaticPublisher' => 'DivinerPublisher', 'DivinerStaticPublisher' => 'DivinerPublisher',

View file

@ -0,0 +1,45 @@
<?php
final class DivinerPHIDTypeBook extends PhabricatorPHIDType {
const TYPECONST = 'BOOK';
public function getTypeConstant() {
return self::TYPECONST;
}
public function getTypeName() {
return pht('Book');
}
public function newObject() {
return new DivinerLiveBook();
}
public function loadObjects(
PhabricatorObjectQuery $query,
array $phids) {
return id(new DivinerBookQuery())
->setViewer($query->getViewer())
->withPHIDs($phids)
->execute();
}
public function loadHandles(
PhabricatorHandleQuery $query,
array $handles,
array $objects) {
foreach ($handles as $phid => $handle) {
$book = $objects[$phid];
$name = $book->getName();
$handle->setName($book->getShortTitle());
$handle->setFullName($book->getTitle());
$handle->setURI("/diviner/book/{$name}/");
}
}
}

View file

@ -28,7 +28,7 @@ final class DivinerLiveBook extends DivinerDAO
public function generatePHID() { public function generatePHID() {
return PhabricatorPHID::generateNewPHID( return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_BOOK); DivinerPHIDTypeBook::TYPECONST);
} }
public function getTitle() { public function getTitle() {

View file

@ -22,7 +22,6 @@ final class PhabricatorPHIDConstants {
const PHID_TYPE_XCMT = 'XCMT'; const PHID_TYPE_XCMT = 'XCMT';
const PHID_TYPE_BOOK = 'BOOK';
const PHID_TYPE_ATOM = 'ATOM'; const PHID_TYPE_ATOM = 'ATOM';
const PHID_TYPE_AUTH = 'AUTH'; const PHID_TYPE_AUTH = 'AUTH';
const PHID_TYPE_XOBJ = 'XOBJ'; const PHID_TYPE_XOBJ = 'XOBJ';