Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phame / controller / post / PhamePostEditController.php
blob88cd109d813042cdc847334359d57943121cc0d3
1 <?php
3 final class PhamePostEditController extends PhamePostController {
5 private $blog;
7 public function setBlog(PhameBlog $blog) {
8 $this->blog = $blog;
9 return $this;
12 public function getBlog() {
13 return $this->blog;
16 public function handleRequest(AphrontRequest $request) {
17 $viewer = $request->getViewer();
18 $id = $request->getURIData('id');
20 if ($id) {
21 $post = id(new PhamePostQuery())
22 ->setViewer($viewer)
23 ->withIDs(array($id))
24 ->executeOne();
25 if (!$post) {
26 return new Aphront404Response();
28 $blog = $post->getBlog();
29 } else {
30 $blog_id = head($request->getArr('blog'));
31 if (!$blog_id) {
32 $blog_id = $request->getStr('blog');
35 $query = id(new PhameBlogQuery())
36 ->setViewer($viewer)
37 ->requireCapabilities(
38 array(
39 PhabricatorPolicyCapability::CAN_VIEW,
40 PhabricatorPolicyCapability::CAN_EDIT,
41 ));
43 if (ctype_digit($blog_id)) {
44 $query->withIDs(array($blog_id));
45 } else {
46 $query->withPHIDs(array($blog_id));
49 $blog = $query->executeOne();
50 if (!$blog) {
51 return new Aphront404Response();
55 $this->setBlog($blog);
57 return id(new PhamePostEditEngine())
58 ->setController($this)
59 ->setBlog($blog)
60 ->buildResponse();
63 protected function buildApplicationCrumbs() {
64 $crumbs = parent::buildApplicationCrumbs();
66 $blog = $this->getBlog();
67 if ($blog) {
68 $crumbs->addTextCrumb(
69 $blog->getName(),
70 $blog->getViewURI());
73 return $crumbs;