[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/diffusion/view/ -> DiffusionEmptyResultView.php (source)

   1  <?php
   2  
   3  final class DiffusionEmptyResultView extends DiffusionView {
   4  
   5    private $browseResultSet;
   6    private $view;
   7  
   8    public function setDiffusionBrowseResultSet(DiffusionBrowseResultSet $set) {
   9      $this->browseResultSet = $set;
  10      return $this;
  11    }
  12  
  13    public function setView($view) {
  14      $this->view = $view;
  15      return $this;
  16    }
  17  
  18    public function render() {
  19      $drequest = $this->getDiffusionRequest();
  20  
  21      $commit = $drequest->getCommit();
  22      $callsign = $drequest->getRepository()->getCallsign();
  23      if ($commit) {
  24        $commit = "r{$callsign}{$commit}";
  25      } else {
  26        $commit = 'HEAD';
  27      }
  28  
  29      $reason = $this->browseResultSet->getReasonForEmptyResultSet();
  30      switch ($reason) {
  31        case DiffusionBrowseResultSet::REASON_IS_NONEXISTENT:
  32          $title = pht('Path Does Not Exist');
  33          // TODO: Under git, this error message should be more specific. It
  34          // may exist on some other branch.
  35          $body  = pht('This path does not exist anywhere.');
  36          $severity = AphrontErrorView::SEVERITY_ERROR;
  37          break;
  38        case DiffusionBrowseResultSet::REASON_IS_EMPTY:
  39          $title = pht('Empty Directory');
  40          $body = pht("This path was an empty directory at %s.\n", $commit);
  41          $severity = AphrontErrorView::SEVERITY_NOTICE;
  42          break;
  43        case DiffusionBrowseResultSet::REASON_IS_DELETED:
  44          $deleted = $this->browseResultSet->getDeletedAtCommit();
  45          $existed = $this->browseResultSet->getExistedAtCommit();
  46  
  47          $browse = $this->linkBrowse(
  48            $drequest->getPath(),
  49            array(
  50              'text' => 'existed',
  51              'commit' => $existed,
  52              'params' => array('view' => $this->view),
  53            ));
  54  
  55          $title = pht('Path Was Deleted');
  56          $body = pht(
  57            'This path does not exist at %s. It was deleted in %s and last %s '.
  58              'at %s.',
  59            $commit,
  60            self::linkCommit($drequest->getRepository(), $deleted),
  61            $browse,
  62            "r{$callsign}{$existed}");
  63          $severity = AphrontErrorView::SEVERITY_WARNING;
  64          break;
  65        case DiffusionBrowseResultSet::REASON_IS_UNTRACKED_PARENT:
  66          $subdir = $drequest->getRepository()->getDetail('svn-subpath');
  67          $title = pht('Directory Not Tracked');
  68          $body =
  69            pht("This repository is configured to track only one subdirectory ".
  70            "of the entire repository ('%s'), ".
  71            "but you aren't looking at something in that subdirectory, so no ".
  72            "information is available.", $subdir);
  73          $severity = AphrontErrorView::SEVERITY_WARNING;
  74          break;
  75        default:
  76          throw new Exception("Unknown failure reason: $reason");
  77      }
  78  
  79      $error_view = new AphrontErrorView();
  80      $error_view->setSeverity($severity);
  81      $error_view->setTitle($title);
  82      $error_view->appendChild(phutil_tag('p', array(), $body));
  83  
  84      return $error_view->render();
  85    }
  86  
  87  }


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