Page MenuHomePhabricator
Diviner Phabricator Tech Docs PhabricatorSettingsPanel

abstract class PhabricatorSettingsPanel
Phabricator Technical Documentation (Settings)

Defines a settings panel. Settings panels appear in the Settings application, and behave like lightweight controllers -- generally, they render some sort of form with options in it, and then update preferences when the user submits the form. By extending this class, you can add new settings panels.

NOTE: This stuff is new and might not be completely stable.

Tasks

Panel Configuration

  • abstract public function getPanelKey() — Return a unique string used in the URI to identify this panel, like "example".
  • abstract public function getPanelName() — Return a human-readable description of the panel's contents, like "Example Settings".
  • abstract public function getPanelGroup() — Return a human-readable group name for this panel. For instance, if you had several related panels like "Volume Settings" and "Microphone Settings", you might put them in a group called "Audio".
  • public function isEnabled() — Return false to prevent this panel from being displayed or used. You can do, e.g., configuration checks here, to determine if the feature your panel controls is unavailble in this install. By default, all panels are enabled.
  • public function buildPanels() — You can use this callback to generate multiple similar panels which all share the same implementation. For example, OAuth providers each have a separate panel, but the implementation for each panel is the same.
  • public function isEditableByAdministrators() — Return true if this panel is available to administrators while editing system agent accounts.

Panel Implementation

  • abstract public function processRequest($request) — Process a user request for this settings panel. Implement this method like a lightweight controller. If you return an @{class:AphrontResponse}, the response will be used in whole. If you return anything else, it will be treated as a view and composed into a normal settings page.
  • final public function getPanelURI($path) — Get the URI for this panel.

Internals

  • final public function getPanelSortKey() — Generates a key to sort the list of panels.

Other Methods

Methods

public function setUser($user)

This method is not documented.
Parameters
PhabricatorUser$user
Return
wild

public function getUser()

This method is not documented.
Return
wild

public function setViewer($viewer)

This method is not documented.
Parameters
PhabricatorUser$viewer
Return
wild

public function getViewer()

This method is not documented.
Return
wild

public function setOverrideURI($override_uri)

This method is not documented.
Parameters
$override_uri
Return
wild

abstract public function getPanelKey()

Return a unique string used in the URI to identify this panel, like "example".

Return
stringUnique panel identifier (used in URIs).

abstract public function getPanelName()

Return a human-readable description of the panel's contents, like "Example Settings".

Return
stringHuman-readable panel name.

abstract public function getPanelGroup()

Return a human-readable group name for this panel. For instance, if you had several related panels like "Volume Settings" and "Microphone Settings", you might put them in a group called "Audio".

When displayed, panels are grouped with other panels that have the same group name.

Return
stringHuman-readable panel group name.

public function isEnabled()

Return false to prevent this panel from being displayed or used. You can do, e.g., configuration checks here, to determine if the feature your panel controls is unavailble in this install. By default, all panels are enabled.

Return
boolTrue if the panel should be shown.

public function buildPanels()

You can use this callback to generate multiple similar panels which all share the same implementation. For example, OAuth providers each have a separate panel, but the implementation for each panel is the same.

To generate multiple panels, build them here and return a list. By default, the current panel ($this) is returned alone. For most panels, this is the right implementation.

Return
list<PhabricatorSettingsPanel>Zero or more panels.

public function isEditableByAdministrators()

Return true if this panel is available to administrators while editing system agent accounts.

Return
boolTrue to enable edit by administrators.

abstract public function processRequest($request)

Process a user request for this settings panel. Implement this method like a lightweight controller. If you return an AphrontResponse, the response will be used in whole. If you return anything else, it will be treated as a view and composed into a normal settings page.

Generally, render your settings panel by returning a form, then return a redirect when the user saves settings.

Parameters
AphrontRequest$requestIncoming request.
Return
wildResponse to request, either as an @{class:AphrontResponse} or something which can be composed into a @{class:AphrontView}.

final public function getPanelURI($path)

Get the URI for this panel.

Parameters
string?$pathOptional path to append.
Return
stringRelative URI for the panel.

final public function getPanelSortKey()

Generates a key to sort the list of panels.

Return
stringSortable key.