Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conduit/method/ConduitAPIMethod.php
| Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | public function getSortOrder() { | ||||
| return "{$head}.{$ord}.{$tail}"; | return "{$head}.{$ord}.{$tail}"; | ||||
| } | } | ||||
| public function getApplicationName() { | public function getApplicationName() { | ||||
| return head(explode('.', $this->getAPIMethodName(), 2)); | return head(explode('.', $this->getAPIMethodName(), 2)); | ||||
| } | } | ||||
| public static function loadAllConduitMethods() { | public static function loadAllConduitMethods() { | ||||
| static $method_map = null; | return id(new PhutilClassMapQuery()) | ||||
| if ($method_map === null) { | |||||
| $methods = id(new PhutilSymbolLoader()) | |||||
| ->setAncestorClass(__CLASS__) | ->setAncestorClass(__CLASS__) | ||||
| ->loadObjects(); | ->setUniqueMethod('getAPIMethodName') | ||||
| ->execute(); | |||||
| foreach ($methods as $method) { | |||||
| $name = $method->getAPIMethodName(); | |||||
| if (empty($method_map[$name])) { | |||||
| $method_map[$name] = $method; | |||||
| continue; | |||||
| } | |||||
| $orig_class = get_class($method_map[$name]); | |||||
| $this_class = get_class($method); | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Two Conduit API method classes (%s, %s) both have the same '. | |||||
| 'method name (%s). API methods must have unique method names.', | |||||
| $orig_class, | |||||
| $this_class, | |||||
| $name)); | |||||
| } | |||||
| } | |||||
| return $method_map; | |||||
| } | } | ||||
| public static function getConduitMethod($method_name) { | public static function getConduitMethod($method_name) { | ||||
| $method_map = self::loadAllConduitMethods(); | $method_map = self::loadAllConduitMethods(); | ||||
| return idx($method_map, $method_name); | return idx($method_map, $method_name); | ||||
| } | } | ||||
| public function shouldRequireAuthentication() { | public function shouldRequireAuthentication() { | ||||
| ▲ Show 20 Lines • Show All 229 Lines • Show Last 20 Lines | |||||