1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-22 11:39:03 +01:00

Return applications in application order

Summary:
By default, order applications in application order. See discussion in D4708.

Principally, this is intended to make sure that application event handlers are registered in order, and thus fire in order.

Test Plan:
Looked at /applications/, homepage tiles, verified they both still work.

I didn't actually test the event handler bit since it's fairly complicated to test blind; D4708 should provide a test case.

Reviewers: btrahan, Afaque_Hussain

Reviewed By: Afaque_Hussain

CC: aran

Differential Revision: https://secure.phabricator.com/D4791
This commit is contained in:
epriestley 2013-02-03 09:26:25 -08:00
parent 5459af3bdd
commit 57ff0a80aa
3 changed files with 21 additions and 22 deletions

View file

@ -244,7 +244,6 @@ abstract class PhabricatorApplication {
}
public static function getAllApplications() {
$classes = id(new PhutilSymbolLoader())
->setAncestorClass(__CLASS__)
->setConcreteOnly(true)
@ -257,6 +256,13 @@ abstract class PhabricatorApplication {
$apps[] = $app;
}
// Reorder the applications into "application order". Notably, this ensures
// their event handlers register in application order.
$apps = msort($apps, 'getApplicationOrder');
$apps = mgroup($apps, 'getApplicationGroup');
$apps = array_select_keys($apps, self::getApplicationGroups()) + $apps;
$apps = array_mergev($apps);
return $apps;
}
@ -270,31 +276,24 @@ abstract class PhabricatorApplication {
PhabricatorEnv::getEnvConfig('phabricator.uninstalled-applications');
if (empty($applications)) {
$classes = id(new PhutilSymbolLoader())
->setAncestorClass(__CLASS__)
->setConcreteOnly(true)
->selectAndLoadSymbols();
$all_applications = self::getAllApplications();
$apps = array();
foreach ($classes as $class) {
if (isset($uninstalled[$class['name']])) {
continue;
}
$app = newv($class['name'], array());
if (!$app->isEnabled()) {
foreach ($all_applications as $app) {
$class = get_class($app);
if (isset($uninstalled[$class])) {
continue;
}
}
if (!$show_beta && $app->isBeta()) {
if (!$app->isEnabled()) {
continue;
}
}
$apps[] = $app;
if (!$show_beta && $app->isBeta()) {
continue;
}
$apps[] = $app;
}
$applications = $apps;

View file

@ -65,8 +65,6 @@ abstract class PhabricatorDirectoryController extends PhabricatorController {
continue;
}
$tile_group = msort($tile_group, 'getApplicationOrder');
$is_small_tiles = ($tile_display == PhabricatorApplication::TILE_SHOW) ||
($tile_display == PhabricatorApplication::TILE_HIDE);

View file

@ -47,6 +47,8 @@ final class PhabricatorApplicationsListController
private function buildInstalledApplicationsList(array $applications) {
$list = new PhabricatorObjectItemListView();
$applications = msort($applications, 'getName');
foreach ($applications as $application) {
$item = id(new PhabricatorObjectItemView())
->setHeader($application->getName())