Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionController.php
| Show First 20 Lines • Show All 281 Lines • ▼ Show 20 Lines | abstract class DiffusionController extends PhabricatorController { | ||||
| } | } | ||||
| protected function renderTablePagerBox(PHUIPagerView $pager) { | protected function renderTablePagerBox(PHUIPagerView $pager) { | ||||
| return id(new PHUIBoxView()) | return id(new PHUIBoxView()) | ||||
| ->addMargin(PHUI::MARGIN_LARGE) | ->addMargin(PHUI::MARGIN_LARGE) | ||||
| ->appendChild($pager); | ->appendChild($pager); | ||||
| } | } | ||||
| protected function renderDirectoryReadme(DiffusionBrowseResultSet $browse) { | |||||
| $readme_path = $browse->getReadmePath(); | |||||
| if ($readme_path === null) { | |||||
| return null; | |||||
| } | |||||
| $drequest = $this->getDiffusionRequest(); | |||||
| $viewer = $this->getViewer(); | |||||
| try { | |||||
| $result = $this->callConduitWithDiffusionRequest( | |||||
| 'diffusion.filecontentquery', | |||||
| array( | |||||
| 'path' => $readme_path, | |||||
| 'commit' => $drequest->getStableCommit(), | |||||
| )); | |||||
| } catch (Exception $ex) { | |||||
| return null; | |||||
| } | |||||
| $file_phid = $result['filePHID']; | |||||
| if (!$file_phid) { | |||||
| return null; | |||||
| } | |||||
| $file = id(new PhabricatorFileQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withPHIDs(array($file_phid)) | |||||
| ->executeOne(); | |||||
| if (!$file) { | |||||
| return null; | |||||
| } | |||||
| $corpus = $file->loadFileData(); | |||||
| if (!strlen($corpus)) { | |||||
| return null; | |||||
| } | |||||
| return id(new DiffusionReadmeView()) | |||||
| ->setUser($this->getViewer()) | |||||
| ->setPath($readme_path) | |||||
| ->setContent($corpus); | |||||
| } | |||||
| } | } | ||||