Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14014429
D13429.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
28 KB
Referenced Files
None
Subscribers
None
D13429.id.diff
View Options
diff --git a/src/applications/almanac/servicetype/AlmanacServiceType.php b/src/applications/almanac/servicetype/AlmanacServiceType.php
--- a/src/applications/almanac/servicetype/AlmanacServiceType.php
+++ b/src/applications/almanac/servicetype/AlmanacServiceType.php
@@ -65,11 +65,11 @@
* @return map<string, object> Dictionary of available service types.
*/
public static function getAllServiceTypes() {
- $types = id(new PhutilSymbolLoader())
+ return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- return msort($types, 'getServiceTypeName');
+ ->setUniqueMethod('getServiceTypeShortName')
+ ->setSortMethod('getServiceTypeName')
+ ->execute();
}
diff --git a/src/applications/auth/factor/PhabricatorAuthFactor.php b/src/applications/auth/factor/PhabricatorAuthFactor.php
--- a/src/applications/auth/factor/PhabricatorAuthFactor.php
+++ b/src/applications/auth/factor/PhabricatorAuthFactor.php
@@ -34,35 +34,10 @@
}
public static function getAllFactors() {
- static $factors;
-
- if ($factors === null) {
- $map = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- $factors = array();
- foreach ($map as $factor) {
- $key = $factor->getFactorKey();
- if (empty($factors[$key])) {
- $factors[$key] = $factor;
- } else {
- $this_class = get_class($factor);
- $that_class = get_class($factors[$key]);
-
- throw new Exception(
- pht(
- 'Two auth factors (with classes "%s" and "%s") both provide '.
- 'implementations with the same key ("%s"). Each factor must '.
- 'have a unique key.',
- $this_class,
- $that_class,
- $key));
- }
- }
- }
-
- return $factors;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getFactorKey')
+ ->execute();
}
protected function newConfigForUser(PhabricatorUser $user) {
diff --git a/src/applications/auth/provider/PhabricatorAuthProvider.php b/src/applications/auth/provider/PhabricatorAuthProvider.php
--- a/src/applications/auth/provider/PhabricatorAuthProvider.php
+++ b/src/applications/auth/provider/PhabricatorAuthProvider.php
@@ -55,16 +55,9 @@
}
public static function getAllBaseProviders() {
- static $providers;
-
- if ($providers === null) {
- $objects = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
- $providers = $objects;
- }
-
- return $providers;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->execute();
}
public static function getAllProviders() {
diff --git a/src/applications/base/PhabricatorApplication.php b/src/applications/base/PhabricatorApplication.php
--- a/src/applications/base/PhabricatorApplication.php
+++ b/src/applications/base/PhabricatorApplication.php
@@ -383,13 +383,13 @@
static $applications;
if ($applications === null) {
- $apps = id(new PhutilSymbolLoader())
+ $apps = id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->loadObjects();
+ ->setSortMethod('getApplicationOrder')
+ ->execute();
// Reorder the applications into "application order". Notably, this
// ensures their event handlers register in application order.
- $apps = msort($apps, 'getApplicationOrder');
$apps = mgroup($apps, 'getApplicationGroup');
$group_order = array_keys(self::getApplicationGroups());
diff --git a/src/applications/celerity/postprocessor/CelerityPostprocessor.php b/src/applications/celerity/postprocessor/CelerityPostprocessor.php
--- a/src/applications/celerity/postprocessor/CelerityPostprocessor.php
+++ b/src/applications/celerity/postprocessor/CelerityPostprocessor.php
@@ -36,34 +36,10 @@
}
final public static function getAllPostprocessors() {
- static $postprocessors;
-
- if ($postprocessors === null) {
- $objects = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- $map = array();
- foreach ($objects as $object) {
- $key = $object->getPostprocessorKey();
- if (empty($map[$key])) {
- $map[$key] = $object;
- continue;
- }
-
- throw new Exception(
- pht(
- 'Two postprocessors (of classes "%s" and "%s") define the same '.
- 'postprocessor key ("%s"). Each postprocessor must define a '.
- 'unique key.',
- get_class($object),
- get_class($map[$key]),
- $key));
- }
- $postprocessors = $map;
- }
-
- return $postprocessors;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getPostprocessorKey')
+ ->execute();
}
}
diff --git a/src/applications/celerity/resources/CelerityPhysicalResources.php b/src/applications/celerity/resources/CelerityPhysicalResources.php
--- a/src/applications/celerity/resources/CelerityPhysicalResources.php
+++ b/src/applications/celerity/resources/CelerityPhysicalResources.php
@@ -23,11 +23,10 @@
static $resources_map;
if ($resources_map === null) {
- $resources_map = array();
-
- $resources_list = id(new PhutilSymbolLoader())
+ $resources_list = id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->loadObjects();
+ ->setUniqueMethod('getName')
+ ->execute();
foreach ($resources_list as $resources) {
$name = $resources->getName();
@@ -39,21 +38,9 @@
'lowercase latin letters and digits.',
$name));
}
-
- if (empty($resources_map[$name])) {
- $resources_map[$name] = $resources;
- } else {
- $old = get_class($resources_map[$name]);
- $new = get_class($resources);
- throw new Exception(
- pht(
- 'Celerity resource maps must have unique names, but maps %s and '.
- '%s share the same name, "%s".',
- $old,
- $new,
- $name));
- }
}
+
+ $resources_map = $resources_list;
}
return $resources_map;
diff --git a/src/applications/config/check/PhabricatorSetupCheck.php b/src/applications/config/check/PhabricatorSetupCheck.php
--- a/src/applications/config/check/PhabricatorSetupCheck.php
+++ b/src/applications/config/check/PhabricatorSetupCheck.php
@@ -112,17 +112,10 @@
}
final public static function loadAllChecks() {
- $symbols = id(new PhutilSymbolLoader())
+ return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->setConcreteOnly(true)
- ->selectAndLoadSymbols();
-
- $checks = array();
- foreach ($symbols as $symbol) {
- $checks[] = newv($symbol['name'], array());
- }
-
- return msort($checks, 'getExecutionOrder');
+ ->setSortMethod('getExecutionOrder')
+ ->execute();
}
final public static function runAllChecks() {
diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
--- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
+++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
@@ -46,36 +46,10 @@
}
public static function getAllPanelTypes() {
- static $types;
-
- if ($types === null) {
- $objects = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- $map = array();
- foreach ($objects as $object) {
- $key = $object->getPanelTypeKey();
- if (!empty($map[$key])) {
- $this_class = get_class($object);
- $that_class = get_class($map[$key]);
- throw new Exception(
- pht(
- 'Two dashboard panels (of classes "%s" and "%s") have the '.
- 'same panel type key ("%s"). Each panel type must have a '.
- 'unique panel type key.',
- $this_class,
- $that_class,
- $key));
- }
-
- $map[$key] = $object;
- }
-
- $types = $map;
- }
-
- return $types;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getPanelTypeKey')
+ ->execute();
}
}
diff --git a/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
--- a/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
+++ b/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
@@ -372,21 +372,9 @@
public static function getAllBlueprintImplementations() {
- static $list = null;
-
- if ($list === null) {
- $blueprints = id(new PhutilSymbolLoader())
- ->setType('class')
- ->setAncestorClass(__CLASS__)
- ->setConcreteOnly(true)
- ->selectAndLoadSymbols();
- $list = ipull($blueprints, 'name', 'name');
- foreach ($list as $class_name => $ignored) {
- $list[$class_name] = newv($class_name, array());
- }
- }
-
- return $list;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->execute();
}
public static function getAllBlueprintImplementationsForResource($type) {
diff --git a/src/applications/fact/engine/PhabricatorFactEngine.php b/src/applications/fact/engine/PhabricatorFactEngine.php
--- a/src/applications/fact/engine/PhabricatorFactEngine.php
+++ b/src/applications/fact/engine/PhabricatorFactEngine.php
@@ -3,17 +3,9 @@
abstract class PhabricatorFactEngine extends Phobject {
final public static function loadAllEngines() {
- $classes = id(new PhutilSymbolLoader())
+ return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->setConcreteOnly(true)
- ->selectAndLoadSymbols();
-
- $objects = array();
- foreach ($classes as $class) {
- $objects[] = newv($class['name'], array());
- }
-
- return $objects;
+ ->execute();
}
public function getFactSpecs(array $fact_types) {
diff --git a/src/applications/files/engine/PhabricatorFileStorageEngine.php b/src/applications/files/engine/PhabricatorFileStorageEngine.php
--- a/src/applications/files/engine/PhabricatorFileStorageEngine.php
+++ b/src/applications/files/engine/PhabricatorFileStorageEngine.php
@@ -224,36 +224,11 @@
* @task load
*/
public static function loadAllEngines() {
- static $engines;
-
- if ($engines === null) {
- $objects = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- $map = array();
- foreach ($objects as $engine) {
- $key = $engine->getEngineIdentifier();
- if (empty($map[$key])) {
- $map[$key] = $engine;
- } else {
- throw new Exception(
- pht(
- 'Storage engines "%s" and "%s" have the same engine '.
- 'identifier "%s". Each storage engine must have a unique '.
- 'identifier.',
- get_class($engine),
- get_class($map[$key]),
- $key));
- }
- }
-
- $map = msort($map, 'getEnginePriority');
-
- $engines = $map;
- }
-
- return $engines;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getEngineIdentifier')
+ ->setSortMethod('getEnginePriority')
+ ->execute();
}
diff --git a/src/applications/files/transform/PhabricatorFileTransform.php b/src/applications/files/transform/PhabricatorFileTransform.php
--- a/src/applications/files/transform/PhabricatorFileTransform.php
+++ b/src/applications/files/transform/PhabricatorFileTransform.php
@@ -28,33 +28,11 @@
}
public static function getAllTransforms() {
- static $map;
-
- if ($map === null) {
- $xforms = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- $result = array();
- foreach ($xforms as $xform_template) {
- foreach ($xform_template->generateTransforms() as $xform) {
- $key = $xform->getTransformKey();
- if (isset($result[$key])) {
- throw new Exception(
- pht(
- 'Two %s objects define the same transform key ("%s"), but '.
- 'each transform must have a unique key.',
- __CLASS__,
- $key));
- }
- $result[$key] = $xform;
- }
- }
-
- $map = $result;
- }
-
- return $map;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setExpandMethod('generateTransforms')
+ ->setUniqueMethod('getTransformKey')
+ ->execute();
}
public static function getTransformByKey($key) {
diff --git a/src/applications/harbormaster/autoplan/HarbormasterBuildAutoplan.php b/src/applications/harbormaster/autoplan/HarbormasterBuildAutoplan.php
--- a/src/applications/harbormaster/autoplan/HarbormasterBuildAutoplan.php
+++ b/src/applications/harbormaster/autoplan/HarbormasterBuildAutoplan.php
@@ -10,35 +10,10 @@
}
public static function getAllAutoplans() {
- static $plans;
-
- if ($plans === null) {
- $objects = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- $map = array();
- foreach ($objects as $object) {
- $key = $object->getAutoplanPlanKey();
- if (!empty($map[$key])) {
- $other = $map[$key];
- throw new Exception(
- pht(
- 'Two build autoplans (of classes "%s" and "%s") define the same '.
- 'key ("%s"). Each autoplan must have a unique key.',
- get_class($other),
- get_class($object),
- $key));
- }
- $map[$key] = $object;
- }
-
- ksort($map);
-
- $plans = $map;
- }
-
- return $plans;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getAutoplanPlanKey')
+ ->execute();
}
}
diff --git a/src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php
--- a/src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php
+++ b/src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php
@@ -8,9 +8,9 @@
private $settings;
public static function getImplementations() {
- return id(new PhutilSymbolLoader())
+ return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->loadObjects();
+ ->execute();
}
public static function getImplementation($class) {
diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php
--- a/src/applications/herald/adapter/HeraldAdapter.php
+++ b/src/applications/herald/adapter/HeraldAdapter.php
@@ -1023,14 +1023,11 @@
}
public static function getAllAdapters() {
- static $adapters;
- if (!$adapters) {
- $adapters = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
- $adapters = msort($adapters, 'getAdapterSortKey');
- }
- return $adapters;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getAdapterContentType')
+ ->setSortMethod('getAdapterSortKey')
+ ->execute();
}
public static function getAdapterForContentType($content_type) {
diff --git a/src/applications/maniphest/export/ManiphestExcelFormat.php b/src/applications/maniphest/export/ManiphestExcelFormat.php
--- a/src/applications/maniphest/export/ManiphestExcelFormat.php
+++ b/src/applications/maniphest/export/ManiphestExcelFormat.php
@@ -3,19 +3,10 @@
abstract class ManiphestExcelFormat extends Phobject {
final public static function loadAllFormats() {
- $classes = id(new PhutilSymbolLoader())
+ return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->setConcreteOnly(true)
- ->selectAndLoadSymbols();
-
- $objects = array();
- foreach ($classes as $class) {
- $objects[$class['name']] = newv($class['name'], array());
- }
-
- $objects = msort($objects, 'getOrder');
-
- return $objects;
+ ->setSortMethod('getOrder')
+ ->execute();
}
abstract public function getName();
diff --git a/src/applications/meta/panel/PhabricatorApplicationConfigurationPanel.php b/src/applications/meta/panel/PhabricatorApplicationConfigurationPanel.php
--- a/src/applications/meta/panel/PhabricatorApplicationConfigurationPanel.php
+++ b/src/applications/meta/panel/PhabricatorApplicationConfigurationPanel.php
@@ -47,27 +47,10 @@
PhabricatorController $controller);
public static function loadAllPanels() {
- $objects = id(new PhutilSymbolLoader())
+ return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- $panels = array();
- foreach ($objects as $object) {
- $key = $object->getPanelKey();
- if (empty($panels[$key])) {
- $panels[$key] = $object;
- } else {
- throw new Exception(
- pht(
- 'Application configuration panels "%s" and "%s" have the same '.
- 'panel key, "%s". Each panel must have a unique key.',
- get_class($object),
- get_class($panels[$key]),
- $key));
- }
- }
-
- return $panels;
+ ->setUniqueMethod('getPanelKey')
+ ->execute();
}
public static function loadAllPanelsForApplication(
diff --git a/src/applications/metamta/command/MetaMTAEmailTransactionCommand.php b/src/applications/metamta/command/MetaMTAEmailTransactionCommand.php
--- a/src/applications/metamta/command/MetaMTAEmailTransactionCommand.php
+++ b/src/applications/metamta/command/MetaMTAEmailTransactionCommand.php
@@ -60,21 +60,11 @@
}
public static function getAllCommands() {
- static $commands;
-
- if ($commands === null) {
- $kinds = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
- $commands = array();
- foreach ($kinds as $kind) {
- foreach ($kind->getCommandObjects() as $command) {
- $commands[] = $command;
- }
- }
- }
-
- return $commands;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setExpandMethod('getCommandObjects')
+ ->setUniqueMethod('getCommand')
+ ->execute();
}
public static function getAllCommandsForObject(
diff --git a/src/applications/nuance/source/NuanceSourceDefinition.php b/src/applications/nuance/source/NuanceSourceDefinition.php
--- a/src/applications/nuance/source/NuanceSourceDefinition.php
+++ b/src/applications/nuance/source/NuanceSourceDefinition.php
@@ -58,31 +58,10 @@
}
public static function getAllDefinitions() {
- static $definitions;
-
- if ($definitions === null) {
- $definitions = array();
-
- $objects = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
- foreach ($objects as $definition) {
- $key = $definition->getSourceTypeConstant();
- $name = $definition->getName();
- if (isset($definitions[$key])) {
- $conflict = $definitions[$key];
- throw new Exception(
- pht(
- 'Definition %s conflicts with definition %s. This is a '.
- 'programming error.',
- $conflict,
- $name));
- }
- $definitions[$key] = $definition;
- }
- }
-
- return $definitions;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getSourceTypeConstant')
+ ->execute();
}
/**
diff --git a/src/applications/passphrase/credentialtype/PassphraseCredentialType.php b/src/applications/passphrase/credentialtype/PassphraseCredentialType.php
--- a/src/applications/passphrase/credentialtype/PassphraseCredentialType.php
+++ b/src/applications/passphrase/credentialtype/PassphraseCredentialType.php
@@ -16,10 +16,10 @@
}
public static function getAllTypes() {
- $types = id(new PhutilSymbolLoader())
+ return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->loadObjects();
- return $types;
+ ->setUniqueMethod('getCredentialType')
+ ->execute();
}
public static function getAllCreateableTypes() {
diff --git a/src/applications/phid/type/PhabricatorPHIDType.php b/src/applications/phid/type/PhabricatorPHIDType.php
--- a/src/applications/phid/type/PhabricatorPHIDType.php
+++ b/src/applications/phid/type/PhabricatorPHIDType.php
@@ -159,37 +159,10 @@
* @return dict<string, PhabricatorPHIDType> Map of type constants to types.
*/
final public static function getAllTypes() {
- static $types;
- if ($types === null) {
- $objects = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- $map = array();
- $original = array();
- foreach ($objects as $object) {
- $type = $object->getTypeConstant();
- if (isset($map[$type])) {
- $that_class = $original[$type];
- $this_class = get_class($object);
- throw new Exception(
- pht(
- "Two %s classes (%s, %s) both handle PHID type '%s'. ".
- "A type may be handled by only one class.",
- __CLASS__,
- $that_class,
- $this_class,
- $type));
- }
-
- $original[$type] = get_class($object);
- $map[$type] = $object;
- }
-
- $types = $map;
- }
-
- return $types;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getTypeConstant')
+ ->execute();
}
diff --git a/src/applications/phortune/provider/PhortunePaymentProvider.php b/src/applications/phortune/provider/PhortunePaymentProvider.php
--- a/src/applications/phortune/provider/PhortunePaymentProvider.php
+++ b/src/applications/phortune/provider/PhortunePaymentProvider.php
@@ -117,9 +117,9 @@
public static function getAllProviders() {
- return id(new PhutilSymbolLoader())
+ return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->loadObjects();
+ ->execute();
}
public function isEnabled() {
diff --git a/src/applications/policy/capability/PhabricatorPolicyCapability.php b/src/applications/policy/capability/PhabricatorPolicyCapability.php
--- a/src/applications/policy/capability/PhabricatorPolicyCapability.php
+++ b/src/applications/policy/capability/PhabricatorPolicyCapability.php
@@ -79,16 +79,10 @@
}
final public static function getCapabilityMap() {
- static $map;
- if ($map === null) {
- $capabilities = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- $map = mpull($capabilities, null, 'getCapabilityKey');
- }
-
- return $map;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getCapabilityKey')
+ ->execute();
}
}
diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
--- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
+++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
@@ -559,11 +559,9 @@
* @task construct
*/
public static function getAllEngines() {
- $engines = id(new PhutilSymbolLoader())
+ return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- return $engines;
+ ->execute();
}
diff --git a/src/applications/search/engine/PhabricatorSearchEngine.php b/src/applications/search/engine/PhabricatorSearchEngine.php
--- a/src/applications/search/engine/PhabricatorSearchEngine.php
+++ b/src/applications/search/engine/PhabricatorSearchEngine.php
@@ -106,35 +106,11 @@
* @task load
*/
public static function loadAllEngines() {
- static $engines;
-
- if ($engines === null) {
- $objects = id(new PhutilSymbolLoader())
- ->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- $map = array();
- foreach ($objects as $engine) {
- $key = $engine->getEngineIdentifier();
- if (empty($map[$key])) {
- $map[$key] = $engine;
- } else {
- throw new Exception(
- pht(
- 'Search engines "%s" and "%s" have the same engine identifier '.
- '"%s". Each storage engine must have a unique identifier.',
- get_class($engine),
- get_class($map[$key]),
- $key));
- }
- }
-
- $map = msort($map, 'getEnginePriority');
-
- $engines = $map;
- }
-
- return $engines;
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getEngineIdentifier')
+ ->setSortMethod('getEnginePriority')
+ ->execute();
}
/**
diff --git a/src/infrastructure/edges/type/PhabricatorEdgeType.php b/src/infrastructure/edges/type/PhabricatorEdgeType.php
--- a/src/infrastructure/edges/type/PhabricatorEdgeType.php
+++ b/src/infrastructure/edges/type/PhabricatorEdgeType.php
@@ -156,39 +156,22 @@
static $type_map;
if ($type_map === null) {
- $types = id(new PhutilSymbolLoader())
+ $types = id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->loadObjects();
-
- $map = array();
-
- foreach ($types as $class => $type) {
- $const = $type->getEdgeConstant();
-
- if (isset($map[$const])) {
- throw new Exception(
- pht(
- 'Two edge types ("%s", "%s") share the same edge constant '.
- '(%d). Each edge type must have a unique constant.',
- $class,
- get_class($map[$const]),
- $const));
- }
-
- $map[$const] = $type;
- }
+ ->setUniqueMethod('getEdgeConstant')
+ ->execute();
// Check that all the inverse edge definitions actually make sense. If
// edge type A says B is its inverse, B must exist and say that A is its
// inverse.
- foreach ($map as $const => $type) {
+ foreach ($types as $const => $type) {
$inverse = $type->getInverseEdgeConstant();
if ($inverse === null) {
continue;
}
- if (empty($map[$inverse])) {
+ if (empty($types[$inverse])) {
throw new Exception(
pht(
'Edge type "%s" ("%d") defines an inverse type ("%d") which '.
@@ -198,7 +181,7 @@
$inverse));
}
- $inverse_inverse = $map[$inverse]->getInverseEdgeConstant();
+ $inverse_inverse = $types[$inverse]->getInverseEdgeConstant();
if ($inverse_inverse !== $const) {
throw new Exception(
pht(
@@ -212,7 +195,7 @@
}
}
- $type_map = $map;
+ $type_map = $types;
}
return $type_map;
diff --git a/src/infrastructure/util/password/PhabricatorPasswordHasher.php b/src/infrastructure/util/password/PhabricatorPasswordHasher.php
--- a/src/infrastructure/util/password/PhabricatorPasswordHasher.php
+++ b/src/infrastructure/util/password/PhabricatorPasswordHasher.php
@@ -212,11 +212,11 @@
* @task hashing
*/
public static function getAllHashers() {
- $objects = id(new PhutilSymbolLoader())
+ $objects = id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
- ->loadObjects();
+ ->setUniqueMethod('getHashName')
+ ->execute();
- $map = array();
foreach ($objects as $object) {
$name = $object->getHashName();
@@ -233,20 +233,9 @@
$maximum_length,
$potential_length));
}
-
- if (isset($map[$name])) {
- throw new Exception(
- pht(
- 'Two hashers use the same hash name ("%s"), "%s" and "%s". Each '.
- 'hasher must have a unique name.',
- $name,
- get_class($object),
- get_class($map[$name])));
- }
- $map[$name] = $object;
}
- return $map;
+ return $objects;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 4, 3:26 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6745624
Default Alt Text
D13429.id.diff (28 KB)
Attached To
Mode
D13429: Use PhutilClassMapQuery
Attached
Detach File
Event Timeline
Log In to Comment