[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/feed/story/ -> PhabricatorFeedStoryCommit.php (source)

   1  <?php
   2  
   3  final class PhabricatorFeedStoryCommit extends PhabricatorFeedStory {
   4  
   5    public function getPrimaryObjectPHID() {
   6      return $this->getValue('commitPHID');
   7    }
   8  
   9    public function getRequiredHandlePHIDs() {
  10      return array(
  11        $this->getValue('committerPHID'),
  12      );
  13    }
  14  
  15    public function renderView() {
  16      $data = $this->getStoryData();
  17  
  18      $author = null;
  19      if ($data->getValue('authorPHID')) {
  20        $author = $this->linkTo($data->getValue('authorPHID'));
  21      } else {
  22        $author = $data->getValue('authorName');
  23      }
  24  
  25      $committer = null;
  26      if ($data->getValue('committerPHID')) {
  27        $committer = $this->linkTo($data->getValue('committerPHID'));
  28      } else if ($data->getValue('committerName')) {
  29        $committer = $data->getValue('committerName');
  30      }
  31  
  32      $commit = $this->linkTo($data->getValue('commitPHID'));
  33  
  34      if (!$committer) {
  35        $committer = $author;
  36        $author = null;
  37      }
  38  
  39      if ($author) {
  40        $title = pht(
  41          '%s committed %s (authored by %s)',
  42          $committer,
  43          $commit,
  44          $author);
  45      } else {
  46        $title = pht(
  47          '%s committed %s',
  48          $committer,
  49          $commit);
  50      }
  51  
  52      $view = $this->newStoryView();
  53      $view->setAppIcon('differential-dark');
  54  
  55      $view->setTitle($title);
  56  
  57      if ($data->getValue('authorPHID')) {
  58        $view->setImage($this->getHandle($data->getAuthorPHID())->getImageURI());
  59      }
  60  
  61      $content = $this->renderSummary($data->getValue('summary'));
  62      $view->appendChild($content);
  63  
  64      return $view;
  65    }
  66  
  67    public function renderText() {
  68      $author = null;
  69      if ($this->getAuthorPHID()) {
  70        $author = $this->getHandle($this->getAuthorPHID())->getLinkName();
  71      } else {
  72        $author = $this->getValue('authorName');
  73      }
  74  
  75      $committer = null;
  76      if ($this->getValue('committerPHID')) {
  77        $committer_handle = $this->getHandle($this->getValue('committerPHID'));
  78        $committer = $committer_handle->getLinkName();
  79      } else if ($this->getValue('committerName')) {
  80        $committer = $this->getValue('committerName');
  81      }
  82  
  83      $commit_handle = $this->getHandle($this->getPrimaryObjectPHID());
  84      $commit_uri = PhabricatorEnv::getURI($commit_handle->getURI());
  85      $commit_name = $commit_handle->getLinkName();
  86  
  87      if (!$committer) {
  88        $committer = $author;
  89        $author = null;
  90      }
  91  
  92      if ($author) {
  93        $text = pht(
  94          '%s committed %s (authored by %s).',
  95          $committer,
  96          $commit_name,
  97          $author);
  98      } else {
  99        $text = pht(
 100          '%s committed %s.',
 101          $committer,
 102          $commit_name);
 103      }
 104  
 105      return $text;
 106    }
 107  
 108  }


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