Differential D21696 Diff 51711 src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php
Show All 32 Lines | final public function getMethodDescription() { | ||||
return pht( | return pht( | ||||
'This is a standard **ApplicationEditor** method which allows you to '. | 'This is a standard **ApplicationEditor** method which allows you to '. | ||||
'create and modify objects by applying transactions. For documentation '. | 'create and modify objects by applying transactions. For documentation '. | ||||
'on these endpoints, see '. | 'on these endpoints, see '. | ||||
'**[[ %s | Conduit API: Using Edit Endpoints ]]**.', | '**[[ %s | Conduit API: Using Edit Endpoints ]]**.', | ||||
PhabricatorEnv::getDoclink('Conduit API: Using Edit Endpoints')); | PhabricatorEnv::getDoclink('Conduit API: Using Edit Endpoints')); | ||||
} | } | ||||
final public function getMethodDocumentation() { | final protected function newDocumentationPages(PhabricatorUser $viewer) { | ||||
$viewer = $this->getViewer(); | |||||
$engine = $this->newEditEngine() | $engine = $this->newEditEngine() | ||||
->setViewer($viewer); | ->setViewer($viewer); | ||||
$types = $engine->getConduitEditTypes(); | $types = $engine->getConduitEditTypes(); | ||||
$out = array(); | $out = array(); | ||||
$out[] = $this->buildEditTypesBoxes($engine, $types); | return $this->buildEditTypesDocumentationPages($viewer, $engine, $types); | ||||
return $out; | |||||
} | } | ||||
private function buildEditTypesBoxes( | private function buildEditTypesDocumentationPages( | ||||
PhabricatorUser $viewer, | |||||
PhabricatorEditEngine $engine, | PhabricatorEditEngine $engine, | ||||
array $types) { | array $types) { | ||||
$boxes = array(); | $pages = array(); | ||||
$summary_info = pht( | $summary_info = pht( | ||||
'This endpoint supports these types of transactions. See below for '. | 'This endpoint supports these types of transactions. See below for '. | ||||
'detailed information about each transaction type.'); | 'detailed information about each transaction type.'); | ||||
$rows = array(); | $rows = array(); | ||||
foreach ($types as $type) { | foreach ($types as $type) { | ||||
$rows[] = array( | $rows[] = array( | ||||
Show All 9 Lines | $summary_table = id(new AphrontTableView($rows)) | ||||
pht('Description'), | pht('Description'), | ||||
)) | )) | ||||
->setColumnClasses( | ->setColumnClasses( | ||||
array( | array( | ||||
'prewrap', | 'prewrap', | ||||
'wide', | 'wide', | ||||
)); | )); | ||||
$boxes[] = id(new PHUIObjectBoxView()) | $title = pht('Transaction Summary'); | ||||
->setHeaderText(pht('Transaction Types')) | $content = array( | ||||
->setCollapsed(true) | $this->buildRemarkup($summary_info), | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | $summary_table, | ||||
->appendChild($this->buildRemarkup($summary_info)) | ); | ||||
->appendChild($summary_table); | |||||
$pages[] = $this->newDocumentationBoxPage($viewer, $title, $content) | |||||
->setAnchor('types'); | |||||
foreach ($types as $type) { | foreach ($types as $type) { | ||||
$section = array(); | $section = array(); | ||||
$section[] = $type->getConduitDescription(); | $section[] = $type->getConduitDescription(); | ||||
$type_documentation = $type->getConduitDocumentation(); | $type_documentation = $type->getConduitDocumentation(); | ||||
if (strlen($type_documentation)) { | if (strlen($type_documentation)) { | ||||
Show All 25 Lines | foreach ($types as $type) { | ||||
)) | )) | ||||
->setColumnClasses( | ->setColumnClasses( | ||||
array( | array( | ||||
'prewrap', | 'prewrap', | ||||
'prewrap', | 'prewrap', | ||||
'wide', | 'wide', | ||||
)); | )); | ||||
$boxes[] = id(new PHUIObjectBoxView()) | $title = $type->getEditType(); | ||||
->setHeaderText(pht('Transaction Type: %s', $type->getEditType())) | $content = array( | ||||
->setCollapsed(true) | $this->buildRemarkup($section), | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | $type_table, | ||||
->appendChild($this->buildRemarkup($section)) | ); | ||||
->appendChild($type_table); | |||||
$pages[] = $this->newDocumentationBoxPage($viewer, $title, $content) | |||||
->setAnchor($type->getEditType()) | |||||
->setIconIcon('fa-pencil'); | |||||
} | } | ||||
return $boxes; | return $pages; | ||||
} | } | ||||
private function buildRemarkup($remarkup) { | private function buildRemarkup($remarkup) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$view = new PHUIRemarkupView($viewer, $remarkup); | $view = new PHUIRemarkupView($viewer, $remarkup); | ||||
Show All 11 Lines |