3 final class PhameBlogQuery
extends PhabricatorCursorPagedPolicyAwareQuery
{
10 private $needBloggers;
11 private $needProfileImage;
12 private $needHeaderImage;
14 public function withIDs(array $ids) {
19 public function withPHIDs(array $phids) {
20 $this->phids
= $phids;
24 public function withDomain($domain) {
25 $this->domain
= $domain;
29 public function withStatuses(array $status) {
30 $this->statuses
= $status;
34 public function needProfileImage($need) {
35 $this->needProfileImage
= $need;
39 public function needHeaderImage($need) {
40 $this->needHeaderImage
= $need;
44 public function newResultObject() {
45 return new PhameBlog();
48 protected function loadPage() {
49 return $this->loadStandardPage($this->newResultObject());
52 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
53 $where = parent
::buildWhereClauseParts($conn);
55 if ($this->statuses
!== null) {
62 if ($this->ids
!== null) {
69 if ($this->phids
!== null) {
76 if ($this->domain
!== null) {
86 protected function didFilterPage(array $blogs) {
87 if ($this->needProfileImage
) {
90 $file_phids = mpull($blogs, 'getProfileImagePHID');
91 $file_phids = array_filter($file_phids);
93 $files = id(new PhabricatorFileQuery())
94 ->setParentQuery($this)
95 ->setViewer($this->getViewer())
96 ->withPHIDs($file_phids)
98 $files = mpull($files, null, 'getPHID');
103 foreach ($blogs as $blog) {
104 $file = idx($files, $blog->getProfileImagePHID());
107 $default = PhabricatorFile
::loadBuiltin(
113 $blog->attachProfileImageFile($file);
117 if ($this->needHeaderImage
) {
118 $file_phids = mpull($blogs, 'getHeaderImagePHID');
119 $file_phids = array_filter($file_phids);
121 $files = id(new PhabricatorFileQuery())
122 ->setParentQuery($this)
123 ->setViewer($this->getViewer())
124 ->withPHIDs($file_phids)
126 $files = mpull($files, null, 'getPHID');
131 foreach ($blogs as $blog) {
132 $file = idx($files, $blog->getHeaderImagePHID());
134 $blog->attachHeaderImageFile($file);
141 public function getQueryApplicationClass() {
142 // TODO: Can we set this without breaking public blogs?
146 protected function getPrimaryTableAlias() {