1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 12:30:56 +01:00

Add badges.edit and badges.search to Conduit API

Summary: Ref T10671

Test Plan: Open Conduit application, open `badges.edit` or `badges.search`, create, edit, or query for a badge.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T10671

Differential Revision: https://secure.phabricator.com/D15622
This commit is contained in:
lkassianik 2016-04-05 11:21:44 -07:00
parent 1914ea28eb
commit 9518a1a9a6
6 changed files with 84 additions and 2 deletions

View file

@ -1878,6 +1878,7 @@ phutil_register_library_map(array(
'PhabricatorBadgesCreateCapability' => 'applications/badges/capability/PhabricatorBadgesCreateCapability.php',
'PhabricatorBadgesDAO' => 'applications/badges/storage/PhabricatorBadgesDAO.php',
'PhabricatorBadgesDefaultEditCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultEditCapability.php',
'PhabricatorBadgesEditConduitAPIMethod' => 'applications/badges/conduit/PhabricatorBadgesEditConduitAPIMethod.php',
'PhabricatorBadgesEditController' => 'applications/badges/controller/PhabricatorBadgesEditController.php',
'PhabricatorBadgesEditEngine' => 'applications/badges/editor/PhabricatorBadgesEditEngine.php',
'PhabricatorBadgesEditRecipientsController' => 'applications/badges/controller/PhabricatorBadgesEditRecipientsController.php',
@ -1892,6 +1893,7 @@ phutil_register_library_map(array(
'PhabricatorBadgesRemoveRecipientsController' => 'applications/badges/controller/PhabricatorBadgesRemoveRecipientsController.php',
'PhabricatorBadgesReplyHandler' => 'applications/badges/mail/PhabricatorBadgesReplyHandler.php',
'PhabricatorBadgesSchemaSpec' => 'applications/badges/storage/PhabricatorBadgesSchemaSpec.php',
'PhabricatorBadgesSearchConduitAPIMethod' => 'applications/badges/conduit/PhabricatorBadgesSearchConduitAPIMethod.php',
'PhabricatorBadgesSearchEngine' => 'applications/badges/query/PhabricatorBadgesSearchEngine.php',
'PhabricatorBadgesTransaction' => 'applications/badges/storage/PhabricatorBadgesTransaction.php',
'PhabricatorBadgesTransactionComment' => 'applications/badges/storage/PhabricatorBadgesTransactionComment.php',
@ -6247,12 +6249,14 @@ phutil_register_library_map(array(
'PhabricatorTokenReceiverInterface',
'PhabricatorFlaggableInterface',
'PhabricatorDestructibleInterface',
'PhabricatorConduitResultInterface',
),
'PhabricatorBadgesCommentController' => 'PhabricatorBadgesController',
'PhabricatorBadgesController' => 'PhabricatorController',
'PhabricatorBadgesCreateCapability' => 'PhabricatorPolicyCapability',
'PhabricatorBadgesDAO' => 'PhabricatorLiskDAO',
'PhabricatorBadgesDefaultEditCapability' => 'PhabricatorPolicyCapability',
'PhabricatorBadgesEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'PhabricatorBadgesEditController' => 'PhabricatorBadgesController',
'PhabricatorBadgesEditEngine' => 'PhabricatorEditEngine',
'PhabricatorBadgesEditRecipientsController' => 'PhabricatorBadgesController',
@ -6267,6 +6271,7 @@ phutil_register_library_map(array(
'PhabricatorBadgesRemoveRecipientsController' => 'PhabricatorBadgesController',
'PhabricatorBadgesReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
'PhabricatorBadgesSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PhabricatorBadgesSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'PhabricatorBadgesSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorBadgesTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorBadgesTransactionComment' => 'PhabricatorApplicationTransactionComment',

View file

@ -0,0 +1,19 @@
<?php
final class PhabricatorBadgesEditConduitAPIMethod
extends PhabricatorEditEngineAPIMethod {
public function getAPIMethodName() {
return 'badges.edit';
}
public function newEditEngine() {
return new PhabricatorBadgesEditEngine();
}
public function getMethodSummary() {
return pht(
'Apply transactions to create a new badge or edit an existing one.');
}
}

View file

@ -0,0 +1,18 @@
<?php
final class PhabricatorBadgesSearchConduitAPIMethod
extends PhabricatorSearchEngineAPIMethod {
public function getAPIMethodName() {
return 'badges.search';
}
public function newSearchEngine() {
return new PhabricatorBadgesSearchEngine();
}
public function getMethodSummary() {
return pht('Read information about badges.');
}
}

View file

@ -81,12 +81,14 @@ final class PhabricatorBadgesEditEngine
->setKey('name')
->setLabel(pht('Name'))
->setDescription(pht('Badge name.'))
->setConduitTypeDescription(pht('New badge name.'))
->setTransactionType(PhabricatorBadgesTransaction::TYPE_NAME)
->setValue($object->getName()),
id(new PhabricatorTextEditField())
->setKey('flavor')
->setLabel(pht('Flavor text'))
->setDescription(pht('Short description of the badge.'))
->setConduitTypeDescription(pht('New badge flavor.'))
->setValue($object->getFlavor())
->setTransactionType(PhabricatorBadgesTransaction::TYPE_FLAVOR),
id(new PhabricatorIconSetEditField())
@ -100,6 +102,8 @@ final class PhabricatorBadgesEditEngine
id(new PhabricatorSelectEditField())
->setKey('quality')
->setLabel(pht('Quality'))
->setDescription(pht('Color and rarity of the badge.'))
->setConduitTypeDescription(pht('New badge quality.'))
->setValue($object->getQuality())
->setTransactionType(PhabricatorBadgesTransaction::TYPE_QUALITY)
->setOptions(PhabricatorBadgesQuality::getDropdownQualityMap()),
@ -107,6 +111,7 @@ final class PhabricatorBadgesEditEngine
->setKey('description')
->setLabel(pht('Description'))
->setDescription(pht('Badge long description.'))
->setConduitTypeDescription(pht('New badge description.'))
->setTransactionType(PhabricatorBadgesTransaction::TYPE_DESCRIPTION)
->setValue($object->getDescription()),
);

View file

@ -7,7 +7,8 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO
PhabricatorSubscribableInterface,
PhabricatorTokenReceiverInterface,
PhabricatorFlaggableInterface,
PhabricatorDestructibleInterface {
PhabricatorDestructibleInterface,
PhabricatorConduitResultInterface {
protected $name;
protected $flavor;
@ -49,6 +50,8 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO
->setQuality(PhabricatorBadgesQuality::DEFAULT_QUALITY)
->setCreatorPHID($actor->getPHID())
->setEditPolicy($edit_policy)
->setFlavor('')
->setDescription('')
->setStatus(self::STATUS_ACTIVE);
}
@ -190,4 +193,36 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO
$this->saveTransaction();
}
/* -( PhabricatorConduitResultInterface )---------------------------------- */
public function getFieldSpecificationsForConduit() {
return array(
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('name')
->setType('string')
->setDescription(pht('The name of the badge.')),
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('creatorPHID')
->setType('phid')
->setDescription(pht('User PHID of the creator.')),
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('status')
->setType('string')
->setDescription(pht('Active or archived status of the badge.')),
);
}
public function getFieldValuesForConduit() {
return array(
'name' => $this->getName(),
'creatorPHID' => $this->getCreatorPHID(),
'status' => $this->getStatus(),
);
}
public function getConduitSearchAttachments() {
return array();
}
}

View file

@ -264,7 +264,7 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('status')
->setType('string')
->setDescription(pht('Active or arhived status of the paste.')),
->setDescription(pht('Active or archived status of the paste.')),
);
}