Changeset View
Changeset View
Standalone View
Standalone View
src/applications/tokens/editor/PhabricatorTokenEditEngine.php
- This file was added.
| <?php | |||||
| final class PhabricatorTokenEditEngine | |||||
| extends PhabricatorEditEngine { | |||||
| const ENGINECONST = 'phabricator.tokens.token'; | |||||
| public function getEngineName() { | |||||
| return pht('Tokens'); | |||||
| } | |||||
| public function getEngineApplicationClass() { | |||||
| return 'PhabricatorTokensApplication'; | |||||
| } | |||||
| public function getSummaryHeader() { | |||||
| return pht('Configure Tokens Forms'); | |||||
| } | |||||
| public function getSummaryText() { | |||||
| return pht('Configure how tokens are created and edited.'); | |||||
| } | |||||
| protected function newEditableObject() { | |||||
| return PhabricatorTokensToken::initializeNewToken($this->getViewer()); | |||||
| } | |||||
| protected function newObjectQuery() { | |||||
| return id(new PhabricatorTokenQuery()); | |||||
| } | |||||
| protected function getObjectCreateTitleText($object) { | |||||
| return pht('Create New Token'); | |||||
| } | |||||
| protected function getObjectEditTitleText($object) { | |||||
| return pht('Edit %s', $object->getName()); | |||||
| } | |||||
| protected function getObjectEditShortText($object) { | |||||
| return $object->getName(); | |||||
| } | |||||
| protected function getObjectCreateShortText() { | |||||
| return pht('Create Token'); | |||||
| } | |||||
| protected function getObjectName() { | |||||
| return pht('Token'); | |||||
| } | |||||
| protected function getObjectCreateCancelURI($object) { | |||||
| return $this->getApplication()->getApplicationURI('/'); | |||||
| } | |||||
| protected function getEditorURI() { | |||||
| return $this->getApplication()->getApplicationURI('/edit/'); | |||||
| } | |||||
| protected function getObjectViewURI($object) { | |||||
| return $object->getViewURI(); | |||||
| } | |||||
| protected function getCreateNewObjectPolicy() { | |||||
| return $this->getApplication()->getPolicy( | |||||
| PhabricatorTokensCreateCapability::CAPABILITY); | |||||
| } | |||||
| protected function buildCustomEditFields($object) { | |||||
| return array( | |||||
| id(new PhabricatorTextEditField()) | |||||
| ->setKey('name') | |||||
| ->setLabel(pht('Name')) | |||||
| ->setDescription(pht('Token name.')) | |||||
| ->setConduitDescription(pht('Retitle the token.')) | |||||
| ->setConduitTypeDescription(pht('New token name.')) | |||||
| ->setTransactionType(PhabricatorTokensTransaction::TYPE_NAME) | |||||
| ->setValue($object->getName()), | |||||
| id(new PhabricatorTextEditField()) | |||||
| ->setKey('flavor') | |||||
| ->setLabel(pht('Flavor')) | |||||
| ->setDescription(pht('Token flavor text.')) | |||||
| ->setConduitDescription(pht('Change the token flavor.')) | |||||
| ->setConduitTypeDescription(pht('New token flavor.')) | |||||
| ->setTransactionType(PhabricatorTokensTransaction::TYPE_FLAVOR) | |||||
| ->setValue($object->getFlavor()), | |||||
| ); | |||||
| } | |||||
| } | |||||