Give AphrontTagView a getViewer(), deprecate getUser()

Summary:
Two minor changes here:

  - Replace `get/setUser()` with `get/setViewer()` for consistency with everything else.
  - `getViewer()` now throws if no viewer is set. We had a lot of code that either "should" check this but didn't, or did check it in an identical way, duplicating work. In contrast, very little code checks for a viewer but works if one is not present.

Test Plan:
  - Grepped for `->user`.
  - Attempted to fix all callsites inside `*View` classes.
  - Browsed around a bunch of applications, particularly Calendar, Differential and Diffusion, which seemed most heavily affected.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D15412
This commit is contained in:
epriestley
2016-03-06 06:26:34 -08:00
parent abb4c03b47
commit aaab1011e5
27 changed files with 134 additions and 126 deletions

View File

@@ -3,7 +3,6 @@
final class PhameBlogListView extends AphrontTagView {
private $blogs;
private $viewer;
public function setBlogs($blogs) {
assert_instances_of($blogs, 'PhameBlog');
@@ -11,11 +10,6 @@ final class PhameBlogListView extends AphrontTagView {
return $this;
}
public function setViewer($viewer) {
$this->viewer = $viewer;
return $this;
}
protected function getTagAttributes() {
$classes = array();
$classes[] = 'phame-blog-list';

View File

@@ -4,7 +4,6 @@ final class PhameDraftListView extends AphrontTagView {
private $posts;
private $blogs;
private $viewer;
public function setPosts($posts) {
assert_instances_of($posts, 'PhamePost');
@@ -18,11 +17,6 @@ final class PhameDraftListView extends AphrontTagView {
return $this;
}
public function setViewer($viewer) {
$this->viewer = $viewer;
return $this;
}
protected function getTagAttributes() {
$classes = array();
$classes[] = 'phame-blog-list';

View File

@@ -4,7 +4,6 @@ final class PhamePostListView extends AphrontTagView {
private $posts;
private $nodata;
private $viewer;
private $showBlog = false;
private $isExternal;
private $isLive;
@@ -25,11 +24,6 @@ final class PhamePostListView extends AphrontTagView {
return $this;
}
public function setViewer($viewer) {
$this->viewer = $viewer;
return $this;
}
public function setIsExternal($is_external) {
$this->isExternal = $is_external;
return $this;
@@ -53,7 +47,7 @@ final class PhamePostListView extends AphrontTagView {
}
protected function getTagContent() {
$viewer = $this->viewer;
$viewer = $this->getViewer();
$posts = $this->posts;
$nodata = $this->nodata;