@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Modernize Phame process handlers

Summary: Converts Phame to use handleRequest where appropriate.

Test Plan: Write some blog posts, publish, edit, view.

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D13677

+31 -63
+4 -10
src/applications/phame/controller/post/PhamePostFramedController.php
··· 2 2 3 3 final class PhamePostFramedController extends PhameController { 4 4 5 - private $id; 6 - 7 - public function willProcessRequest(array $data) { 8 - $this->id = $data['id']; 9 - } 10 - 11 - public function processRequest() { 12 - $request = $this->getRequest(); 13 - $user = $request->getUser(); 5 + public function handleRequest(AphrontRequest $request) { 6 + $user = $request->getViewer(); 7 + $id = $request->getURIData('id'); 14 8 15 9 $post = id(new PhamePostQuery()) 16 10 ->setViewer($user) 17 - ->withIDs(array($this->id)) 11 + ->withIDs(array($id)) 18 12 ->requireCapabilities( 19 13 array( 20 14 PhabricatorPolicyCapability::CAN_EDIT,
+18 -26
src/applications/phame/controller/post/PhamePostListController.php
··· 2 2 3 3 final class PhamePostListController extends PhameController { 4 4 5 - private $bloggername; 6 - private $filter; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->filter = idx($data, 'filter', 'blogger'); 10 - $this->bloggername = idx($data, 'bloggername'); 11 - } 12 - 13 - public function processRequest() { 14 - $request = $this->getRequest(); 15 - $user = $request->getUser(); 5 + public function handleRequest(AphrontRequest $request) { 6 + $viewer = $request->getViewer(); 7 + $filter = $request->getURIData('filter'); 8 + $bloggername = $request->getURIData('bloggername'); 16 9 17 10 $query = id(new PhamePostQuery()) 18 - ->setViewer($user); 11 + ->setViewer($viewer); 19 12 20 13 $nav = $this->renderSideNavFilterView(); 21 14 $nodata = null; 22 15 23 - switch ($this->filter) { 16 + switch ($filter) { 24 17 case 'draft': 25 - $query->withBloggerPHIDs(array($user->getPHID())); 18 + $query->withBloggerPHIDs(array($viewer->getPHID())); 26 19 $query->withVisibility(PhamePost::VISIBILITY_DRAFT); 27 20 $nodata = pht('You have no unpublished drafts.'); 28 21 $title = pht('Unpublished Drafts'); 29 22 $nav->selectFilter('post/draft'); 30 23 break; 24 + case 'all': 25 + $nodata = pht('There are no visible posts.'); 26 + $title = pht('Posts'); 27 + $nav->selectFilter('post/all'); 28 + break; 29 + default: 31 30 case 'blogger': 32 - if ($this->bloggername) { 31 + if ($bloggername) { 33 32 $blogger = id(new PhabricatorUser())->loadOneWhere( 34 33 'username = %s', 35 - $this->bloggername); 34 + $bloggername); 36 35 if (!$blogger) { 37 36 return new Aphront404Response(); 38 37 } 39 38 } else { 40 - $blogger = $user; 39 + $blogger = $viewer; 41 40 } 42 41 43 42 $query->withBloggerPHIDs(array($blogger->getPHID())); 44 - if ($blogger->getPHID() == $user->getPHID()) { 43 + if ($blogger->getPHID() == $viewer->getPHID()) { 45 44 $nav->selectFilter('post'); 46 45 $nodata = pht('You have not written any posts.'); 47 46 } else { ··· 49 48 } 50 49 $title = pht('Posts by %s', $blogger); 51 50 break; 52 - case 'all': 53 - $nodata = pht('There are no visible posts.'); 54 - $title = pht('Posts'); 55 - $nav->selectFilter('post/all'); 56 - break; 57 - default: 58 - throw new Exception(pht("Unknown filter '%s'!", $this->filter)); 59 51 } 60 52 61 53 $pager = id(new AphrontCursorPagerView()) ··· 64 56 $posts = $query->executeWithCursorPager($pager); 65 57 66 58 require_celerity_resource('phame-css'); 67 - $post_list = $this->renderPostList($posts, $user, $nodata); 59 + $post_list = $this->renderPostList($posts, $viewer, $nodata); 68 60 $post_list = id(new PHUIObjectBoxView()) 69 61 ->setHeaderText($title) 70 62 ->appendChild($post_list);
+3 -9
src/applications/phame/controller/post/PhamePostNotLiveController.php
··· 2 2 3 3 final class PhamePostNotLiveController extends PhameController { 4 4 5 - private $id; 6 - 7 - public function willProcessRequest(array $data) { 8 - $this->id = $data['id']; 9 - } 10 - 11 - public function processRequest() { 12 - $request = $this->getRequest(); 5 + public function handleRequest(AphrontRequest $request) { 13 6 $user = $request->getUser(); 7 + $id = $request->getURIData('id'); 14 8 15 9 $post = id(new PhamePostQuery()) 16 10 ->setViewer($user) 17 - ->withIDs(array($this->id)) 11 + ->withIDs(array($id)) 18 12 ->executeOne(); 19 13 if (!$post) { 20 14 return new Aphront404Response();
+3 -9
src/applications/phame/controller/post/PhamePostPublishController.php
··· 2 2 3 3 final class PhamePostPublishController extends PhameController { 4 4 5 - private $id; 6 - 7 - public function willProcessRequest(array $data) { 8 - $this->id = $data['id']; 9 - } 10 - 11 - public function processRequest() { 12 - $request = $this->getRequest(); 5 + public function handleRequest(AphrontRequest $request) { 13 6 $user = $request->getUser(); 7 + $id = $request->getURIData('id'); 14 8 15 9 $post = id(new PhamePostQuery()) 16 10 ->setViewer($user) 17 - ->withIDs(array($this->id)) 11 + ->withIDs(array($id)) 18 12 ->requireCapabilities( 19 13 array( 20 14 PhabricatorPolicyCapability::CAN_EDIT,
+3 -9
src/applications/phame/controller/post/PhamePostUnpublishController.php
··· 2 2 3 3 final class PhamePostUnpublishController extends PhameController { 4 4 5 - private $id; 6 - 7 - public function willProcessRequest(array $data) { 8 - $this->id = $data['id']; 9 - } 10 - 11 - public function processRequest() { 12 - $request = $this->getRequest(); 5 + public function handleRequest(AphrontRequest $request) { 13 6 $user = $request->getUser(); 7 + $id = $request->getURIData('id'); 14 8 15 9 $post = id(new PhamePostQuery()) 16 10 ->setViewer($user) 17 - ->withIDs(array($this->id)) 11 + ->withIDs(array($id)) 18 12 ->requireCapabilities( 19 13 array( 20 14 PhabricatorPolicyCapability::CAN_EDIT,