final public function setViewer($viewer)
Set the current viewer.
Some parameter types perform complex parsing involving lookups. For example, a type might lookup usernames or project names. These types need to use the current viewer to execute queries.
PhabricatorUser | $viewer | Current viewer. |
this |
final public function getViewer()
Get the current viewer.
PhabricatorUser | Current viewer. |
final public function getExists($request, $key)
Test if a value is present in a request.
AphrontRequest | $request | The incoming request. |
string | $key | The key to examine. |
bool | True if a readable value is present in the request. |
final public function getValue($request, $key)
Read a value from a request.
If the value is not present, a default value is returned (usually null). Use getExists() to test if a value is present.
AphrontRequest | $request | The incoming request. |
string | $key | The key to examine. |
wild | Value, or default if value is not present. |
final public function getDefaultValue()
Get the default value for this parameter type.
wild | Default value for this type. |
final public function getTypeName()
Get a short name for this type, like string or list<phid>.
string | Short type name. |
final public function getFormatDescriptions()
Get a list of human-readable descriptions of acceptable formats for this type.
For example, a type might return strings like these:
Any positive integer. A comma-separated list of PHIDs.
This is used to explain to users how to specify a type when generating documentation.
list<string> | Human-readable list of acceptable formats. |
final public function getExamples()
Get a list of human-readable examples of how to format this type as an HTTP GET parameter.
For example, a type might return strings like these:
v=123 v[]=1&v[]=2
This is used to show users how to specify parameters of this type in generated documentation.
list<string> | Human-readable list of format examples. |
final protected function getExistsWithType($type, $request, $key)
Call another type's existence check.
This method allows a type to reuse the existence behavior of a different type. For example, a "list of users" type may have the same basic existence check that a simpler "list of strings" type has, and can just call the simpler type to reuse its behavior.
AphrontHTTPParameterType | $type | The other type. |
AphrontRequest | $request | Incoming request. |
string | $key | Key to examine. |
bool | True if the parameter exists. |
final protected function getValueWithType($type, $request, $key)
Call another type's value parser.
This method allows a type to reuse the parsing behavior of a different type. For example, a "list of users" type may start by running the same basic parsing that a simpler "list of strings" type does.
AphrontHTTPParameterType | $type | The other type. |
AphrontRequest | $request | Incoming request. |
string | $key | Key to examine. |
wild | Parsed value. |
final public static function getAllTypes()
Get a list of all available parameter types.
list<AphrontHTTPParameterType> | List of all available types. |
protected function getParameterExists($request, $key)
Test if a parameter exists in a request.
See getExists(). By default, this method tests if the key is present in the request.
To call another type's behavior in order to perform this check, use getExistsWithType().
AphrontRequest | $request | The incoming request. |
string | $key | The key to examine. |
bool | True if a readable value is present in the request. |
abstract protected function getParameterValue($request, $key)
Parse a value from a request.
See getValue(). This method will only be called if this type has already asserted that the value exists with getParameterExists().
To call another type's behavior in order to parse a value, use getValueWithType().
AphrontRequest | $request | The incoming request. |
string | $key | The key to examine. |
wild | Parsed value. |
abstract protected function getParameterTypeName()
Return a simple type name string, like "string" or "list<phid>".
See getTypeName().
string | Short type name. |
abstract protected function getParameterFormatDescriptions()
Return a human-readable list of format descriptions.
list<string> | Human-readable list of acceptable formats. |
abstract protected function getParameterExamples()
Return a human-readable list of examples.
See getExamples().
list<string> | Human-readable list of format examples. |
protected function getParameterDefault()
Return the default value for this parameter type.
See getDefaultValue(). If unspecified, the default is null.
wild | Default value. |