mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
156b156e77
Summary: Ref T7803. Ref T5873. I want to drive Conduit through more shared infrastructure, but can't currently add parameters automatically. Put a `getX()` around the `defineX()` methods so the parent can provide default behaviors. Also like 60% of methods don't define any special error types; don't require them to implement this method. I want to move away from this in general. Test Plan: - Ran `arc unit --everything`. - Called `conduit.query`. - Browsed Conduit UI. Reviewers: btrahan Reviewed By: btrahan Subscribers: hach-que, epriestley Maniphest Tasks: T5873, T7803 Differential Revision: https://secure.phabricator.com/D12380
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class DiffusionFileContentQueryConduitAPIMethod
|
|
extends DiffusionQueryConduitAPIMethod {
|
|
|
|
public function getAPIMethodName() {
|
|
return 'diffusion.filecontentquery';
|
|
}
|
|
|
|
public function getMethodDescription() {
|
|
return 'Retrieve file content from a repository.';
|
|
}
|
|
|
|
protected function defineReturnType() {
|
|
return 'array';
|
|
}
|
|
|
|
protected function defineCustomParamTypes() {
|
|
return array(
|
|
'path' => 'required string',
|
|
'commit' => 'required string',
|
|
'needsBlame' => 'optional bool',
|
|
);
|
|
}
|
|
|
|
protected function getResult(ConduitAPIRequest $request) {
|
|
$drequest = $this->getDiffusionRequest();
|
|
$needs_blame = $request->getValue('needsBlame');
|
|
$file_query = DiffusionFileContentQuery::newFromDiffusionRequest(
|
|
$drequest);
|
|
$file_query
|
|
->setViewer($request->getUser())
|
|
->setNeedsBlame($needs_blame);
|
|
$file_content = $file_query->loadFileContent();
|
|
if ($needs_blame) {
|
|
list($text_list, $rev_list, $blame_dict) = $file_query->getBlameData();
|
|
} else {
|
|
$text_list = $rev_list = $blame_dict = array();
|
|
}
|
|
$file_content
|
|
->setBlameDict($blame_dict)
|
|
->setRevList($rev_list)
|
|
->setTextList($text_list);
|
|
return $file_content->toDictionary();
|
|
}
|
|
|
|
}
|