1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Code Refactored

Summary: Code Refactored as suggested by epriestley

Test Plan: Same test plan as of Installation & Uninstallation of Applications

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4740
This commit is contained in:
Afaque Hussain 2013-01-30 10:53:43 -08:00 committed by epriestley
parent bdecadfd11
commit cc95818384
3 changed files with 27 additions and 12 deletions

View file

@ -227,6 +227,20 @@ abstract class PhabricatorApplication {
/* -( Application Management )--------------------------------------------- */ /* -( Application Management )--------------------------------------------- */
public static function getByClass($class_name) {
$selected = null;
$applications = PhabricatorApplication::getAllApplications();
foreach ($applications as $application) {
if (get_class($application) == $class_name) {
$selected = $application;
break;
}
}
return $selected;
}
public static function getAllApplications() { public static function getAllApplications() {
$classes = id(new PhutilSymbolLoader()) $classes = id(new PhutilSymbolLoader())

View file

@ -13,15 +13,7 @@ final class PhabricatorApplicationDetailViewController
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$selected = null; $selected = PhabricatorApplication::getByClass($this->application);
$applications = PhabricatorApplication::getAllApplications();
foreach ($applications as $application) {
if (get_class($application) == $this->application) {
$selected = $application;
break;
}
}
if (!$selected) { if (!$selected) {
return new Aphront404Response(); return new Aphront404Response();

View file

@ -14,7 +14,12 @@ final class PhabricatorApplicationUninstallController
public function processRequest() { public function processRequest() {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$app_name = substr($this->application, strlen('PhabricatorApplication'));
$selected = PhabricatorApplication::getByClass($this->application);
if (!$selected) {
return new Aphront404Response();
}
if ($request->isDialogFormPost()) { if ($request->isDialogFormPost()) {
$this->manageApplication(); $this->manageApplication();
@ -26,14 +31,18 @@ final class PhabricatorApplicationUninstallController
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setUser($user) ->setUser($user)
->setTitle('Confirmation') ->setTitle('Confirmation')
->appendChild('Install '. $app_name. ' application ?') ->appendChild(
'Install '. $selected->getName(). ' application ?'
)
->addSubmitButton('Install') ->addSubmitButton('Install')
->addCancelButton('/applications/view/'.$this->application); ->addCancelButton('/applications/view/'.$this->application);
} else { } else {
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setUser($user) ->setUser($user)
->setTitle('Confirmation') ->setTitle('Confirmation')
->appendChild('Really Uninstall '. $app_name. ' application ?') ->appendChild(
'Really Uninstall '. $selected->getName(). ' application ?'
)
->addSubmitButton('Uninstall') ->addSubmitButton('Uninstall')
->addCancelButton('/applications/view/'.$this->application); ->addCancelButton('/applications/view/'.$this->application);
} }