Viewerize ArcBundle file loading callbacks
Summary: Ref T603. Clean these up and move them to a single place. Test Plan: - Downloaded a raw diff. - Enabled "attach diffs", created a revision, got an email with a diff. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D7179
This commit is contained in:
27
src/applications/files/query/PhabricatorFileBundleLoader.php
Normal file
27
src/applications/files/query/PhabricatorFileBundleLoader.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Callback provider for loading @{class@arcanist:ArcanistBundle} file data
|
||||
* stored in the Files application.
|
||||
*/
|
||||
final class PhabricatorFileBundleLoader {
|
||||
|
||||
private $viewer;
|
||||
|
||||
public function setViewer(PhabricatorUser $viewer) {
|
||||
$this->viewer = $viewer;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function loadFileData($phid) {
|
||||
$file = id(new PhabricatorFileQuery())
|
||||
->setViewer($this->viewer)
|
||||
->withPHIDs(array($phid))
|
||||
->executeOne();
|
||||
if (!$file) {
|
||||
return null;
|
||||
}
|
||||
return $file->loadFileData();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user