mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-03 07:59:15 +01:00
Summary: Ref T4103. Settings panels are grouped into categories of similar panels (like "Email" or "Sessions and Logs"). Currently, this is done informally, by just grouping and ordering by strings. This won't work well with translations, since it means the ordering is entirely dependent on the language order, so the first settings panel you see might be something irrelvant or confusing. We'd also potentially break third-party stuff by changing strings, but do so in a silent hard-to-detect way. Provide formal objects and modularize the panel groups completely. Test Plan: Verified all panels still appear properly and in the same groups and order. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4103 Differential Revision: https://secure.phabricator.com/D16020
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
abstract class PhabricatorSettingsPanelGroup extends Phobject {
|
|
|
|
private $panels;
|
|
|
|
abstract public function getPanelGroupName();
|
|
|
|
protected function getPanelGroupOrder() {
|
|
return 1000;
|
|
}
|
|
|
|
final public function getPanelGroupOrderVector() {
|
|
return id(new PhutilSortVector())
|
|
->addInt($this->getPanelGroupOrder())
|
|
->addString($this->getPanelGroupName());
|
|
}
|
|
|
|
final public function getPanelGroupKey() {
|
|
return $this->getPhobjectClassConstant('PANELGROUPKEY');
|
|
}
|
|
|
|
final public static function getAllPanelGroups() {
|
|
$groups = id(new PhutilClassMapQuery())
|
|
->setAncestorClass(__CLASS__)
|
|
->setUniqueMethod('getPanelGroupKey')
|
|
->execute();
|
|
|
|
return msortv($groups, 'getPanelGroupOrderVector');
|
|
}
|
|
|
|
final public static function getAllPanelGroupsWithPanels() {
|
|
$groups = self::getAllPanelGroups();
|
|
|
|
$panels = PhabricatorSettingsPanel::getAllPanels();
|
|
$panels = mgroup($panels, 'getPanelGroupKey');
|
|
foreach ($groups as $key => $group) {
|
|
$group->panels = idx($panels, $key, array());
|
|
}
|
|
|
|
return $groups;
|
|
}
|
|
|
|
public function getPanels() {
|
|
return $this->panels;
|
|
}
|
|
|
|
}
|