mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42: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:
parent
bdecadfd11
commit
cc95818384
3 changed files with 27 additions and 12 deletions
|
@ -227,6 +227,20 @@ abstract class PhabricatorApplication {
|
|||
|
||||
/* -( 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() {
|
||||
|
||||
$classes = id(new PhutilSymbolLoader())
|
||||
|
|
|
@ -13,15 +13,7 @@ final class PhabricatorApplicationDetailViewController
|
|||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$selected = null;
|
||||
$applications = PhabricatorApplication::getAllApplications();
|
||||
|
||||
foreach ($applications as $application) {
|
||||
if (get_class($application) == $this->application) {
|
||||
$selected = $application;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$selected = PhabricatorApplication::getByClass($this->application);
|
||||
|
||||
if (!$selected) {
|
||||
return new Aphront404Response();
|
||||
|
|
|
@ -14,7 +14,12 @@ final class PhabricatorApplicationUninstallController
|
|||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$app_name = substr($this->application, strlen('PhabricatorApplication'));
|
||||
|
||||
$selected = PhabricatorApplication::getByClass($this->application);
|
||||
|
||||
if (!$selected) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
if ($request->isDialogFormPost()) {
|
||||
$this->manageApplication();
|
||||
|
@ -26,14 +31,18 @@ final class PhabricatorApplicationUninstallController
|
|||
$dialog = id(new AphrontDialogView())
|
||||
->setUser($user)
|
||||
->setTitle('Confirmation')
|
||||
->appendChild('Install '. $app_name. ' application ?')
|
||||
->appendChild(
|
||||
'Install '. $selected->getName(). ' application ?'
|
||||
)
|
||||
->addSubmitButton('Install')
|
||||
->addCancelButton('/applications/view/'.$this->application);
|
||||
} else {
|
||||
$dialog = id(new AphrontDialogView())
|
||||
->setUser($user)
|
||||
->setTitle('Confirmation')
|
||||
->appendChild('Really Uninstall '. $app_name. ' application ?')
|
||||
->appendChild(
|
||||
'Really Uninstall '. $selected->getName(). ' application ?'
|
||||
)
|
||||
->addSubmitButton('Uninstall')
|
||||
->addCancelButton('/applications/view/'.$this->application);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue