[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/differential/render/ -> DifferentialRawDiffRenderer.php (source)

   1  <?php
   2  final class DifferentialRawDiffRenderer {
   3  
   4    private $changesets;
   5    private $format = 'unified';
   6    private $viewer;
   7  
   8    public function setFormat($format) {
   9      $this->format = $format;
  10      return $this;
  11    }
  12  
  13    public function getFormat() {
  14      return $this->format;
  15    }
  16  
  17    public function setChangesets(array $changesets) {
  18      assert_instances_of($changesets, 'DifferentialChangeset');
  19  
  20      $this->changesets = $changesets;
  21      return $this;
  22    }
  23  
  24    public function getChangesets() {
  25      return $this->changesets;
  26    }
  27  
  28    public function setViewer(PhabricatorUser $viewer) {
  29      $this->viewer = $viewer;
  30      return $this;
  31    }
  32  
  33    public function getViewer() {
  34      return $this->viewer;
  35    }
  36  
  37    public function buildPatch() {
  38      $diff = new DifferentialDiff();
  39      $diff->attachChangesets($this->getChangesets());
  40  
  41      $raw_changes = $diff->buildChangesList();
  42      $changes = array();
  43      foreach ($raw_changes as $changedict) {
  44        $changes[] = ArcanistDiffChange::newFromDictionary($changedict);
  45      }
  46  
  47      $viewer = $this->getViewer();
  48      $loader = id(new PhabricatorFileBundleLoader())
  49        ->setViewer($viewer);
  50  
  51      $bundle = ArcanistBundle::newFromChanges($changes);
  52      $bundle->setLoadFileDataCallback(array($loader, 'loadFileData'));
  53  
  54      $format = $this->getFormat();
  55      switch ($format) {
  56        case 'git':
  57          return $bundle->toGitPatch();
  58          break;
  59        case 'unified':
  60        default:
  61          return $bundle->toUnifiedDiff();
  62          break;
  63      }
  64    }
  65  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1