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 buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
49 $where = parent
::buildWhereClauseParts($conn);
51 if ($this->statuses
!== null) {
58 if ($this->ids
!== null) {
65 if ($this->phids
!== null) {
72 if ($this->domain
!== null) {
82 protected function didFilterPage(array $blogs) {
83 if ($this->needProfileImage
) {
86 $file_phids = mpull($blogs, 'getProfileImagePHID');
87 $file_phids = array_filter($file_phids);
89 $files = id(new PhabricatorFileQuery())
90 ->setParentQuery($this)
91 ->setViewer($this->getViewer())
92 ->withPHIDs($file_phids)
94 $files = mpull($files, null, 'getPHID');
99 foreach ($blogs as $blog) {
100 $file = idx($files, $blog->getProfileImagePHID());
103 $default = PhabricatorFile
::loadBuiltin(
109 $blog->attachProfileImageFile($file);
113 if ($this->needHeaderImage
) {
114 $file_phids = mpull($blogs, 'getHeaderImagePHID');
115 $file_phids = array_filter($file_phids);
117 $files = id(new PhabricatorFileQuery())
118 ->setParentQuery($this)
119 ->setViewer($this->getViewer())
120 ->withPHIDs($file_phids)
122 $files = mpull($files, null, 'getPHID');
127 foreach ($blogs as $blog) {
128 $file = idx($files, $blog->getHeaderImagePHID());
130 $blog->attachHeaderImageFile($file);
137 public function getQueryApplicationClass() {
138 // TODO: Can we set this without breaking public blogs?
142 protected function getPrimaryTableAlias() {