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:
epriestley
2013-09-30 12:21:33 -07:00
parent 13dae05193
commit dd206a5b69
4 changed files with 43 additions and 25 deletions

View 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();
}
}