Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15234053
D15346.id37005.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
29 KB
Referenced Files
None
Subscribers
None
D15346.id37005.diff
View Options
diff --git a/resources/sql/autopatches/20160225.almanac.2.stype.sql b/resources/sql/autopatches/20160225.almanac.2.stype.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160225.almanac.2.stype.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_almanac.almanac_service
+ CHANGE serviceClass serviceType VARCHAR(64) NOT NULL COLLATE {$COLLATE_TEXT};
diff --git a/resources/sql/autopatches/20160225.almanac.3.stype.php b/resources/sql/autopatches/20160225.almanac.3.stype.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160225.almanac.3.stype.php
@@ -0,0 +1,30 @@
+<?php
+
+// Previously, Almanac services stored a "serviceClass". Migrate these to
+// new "serviceType" values.
+
+$table = new AlmanacService();
+$conn_w = $table->establishConnection('w');
+
+foreach (new LiskMigrationIterator($table) as $service) {
+
+ $new_type = null;
+ try {
+ $old_type = $service->getServiceType();
+ $object = newv($old_type, array());
+ $new_type = $object->getServiceTypeConstant();
+ } catch (Exception $ex) {
+ continue;
+ }
+
+ if (!$new_type) {
+ continue;
+ }
+
+ queryfx(
+ $conn_w,
+ 'UPDATE %T SET serviceType = %s WHERE id = %d',
+ $table->getTableName(),
+ $new_type,
+ $service->getID());
+}
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -25,7 +25,6 @@
'AlmanacClusterDatabaseServiceType' => 'applications/almanac/servicetype/AlmanacClusterDatabaseServiceType.php',
'AlmanacClusterRepositoryServiceType' => 'applications/almanac/servicetype/AlmanacClusterRepositoryServiceType.php',
'AlmanacClusterServiceType' => 'applications/almanac/servicetype/AlmanacClusterServiceType.php',
- 'AlmanacConduitAPIMethod' => 'applications/almanac/conduit/AlmanacConduitAPIMethod.php',
'AlmanacConsoleController' => 'applications/almanac/controller/AlmanacConsoleController.php',
'AlmanacController' => 'applications/almanac/controller/AlmanacController.php',
'AlmanacCreateDevicesCapability' => 'applications/almanac/capability/AlmanacCreateDevicesCapability.php',
@@ -101,8 +100,6 @@
'AlmanacPropertyInterface' => 'applications/almanac/property/AlmanacPropertyInterface.php',
'AlmanacPropertyQuery' => 'applications/almanac/query/AlmanacPropertyQuery.php',
'AlmanacQuery' => 'applications/almanac/query/AlmanacQuery.php',
- 'AlmanacQueryDevicesConduitAPIMethod' => 'applications/almanac/conduit/AlmanacQueryDevicesConduitAPIMethod.php',
- 'AlmanacQueryServicesConduitAPIMethod' => 'applications/almanac/conduit/AlmanacQueryServicesConduitAPIMethod.php',
'AlmanacSchemaSpec' => 'applications/almanac/storage/AlmanacSchemaSpec.php',
'AlmanacSearchEngineAttachment' => 'applications/almanac/engineextension/AlmanacSearchEngineAttachment.php',
'AlmanacService' => 'applications/almanac/storage/AlmanacService.php',
@@ -120,6 +117,7 @@
'AlmanacServiceTransaction' => 'applications/almanac/storage/AlmanacServiceTransaction.php',
'AlmanacServiceTransactionQuery' => 'applications/almanac/query/AlmanacServiceTransactionQuery.php',
'AlmanacServiceType' => 'applications/almanac/servicetype/AlmanacServiceType.php',
+ 'AlmanacServiceTypeDatasource' => 'applications/almanac/typeahead/AlmanacServiceTypeDatasource.php',
'AlmanacServiceTypeTestCase' => 'applications/almanac/servicetype/__tests__/AlmanacServiceTypeTestCase.php',
'AlmanacServiceViewController' => 'applications/almanac/controller/AlmanacServiceViewController.php',
'AlmanacTransaction' => 'applications/almanac/storage/AlmanacTransaction.php',
@@ -4012,7 +4010,6 @@
'AlmanacClusterDatabaseServiceType' => 'AlmanacClusterServiceType',
'AlmanacClusterRepositoryServiceType' => 'AlmanacClusterServiceType',
'AlmanacClusterServiceType' => 'AlmanacServiceType',
- 'AlmanacConduitAPIMethod' => 'ConduitAPIMethod',
'AlmanacConsoleController' => 'AlmanacController',
'AlmanacController' => 'PhabricatorController',
'AlmanacCreateDevicesCapability' => 'PhabricatorPolicyCapability',
@@ -4120,8 +4117,6 @@
'AlmanacPropertyEditEngine' => 'PhabricatorEditEngine',
'AlmanacPropertyQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'AlmanacQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
- 'AlmanacQueryDevicesConduitAPIMethod' => 'AlmanacConduitAPIMethod',
- 'AlmanacQueryServicesConduitAPIMethod' => 'AlmanacConduitAPIMethod',
'AlmanacSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'AlmanacSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
'AlmanacService' => array(
@@ -4149,6 +4144,7 @@
'AlmanacServiceTransaction' => 'AlmanacTransaction',
'AlmanacServiceTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'AlmanacServiceType' => 'Phobject',
+ 'AlmanacServiceTypeDatasource' => 'PhabricatorTypeaheadDatasource',
'AlmanacServiceTypeTestCase' => 'PhabricatorTestCase',
'AlmanacServiceViewController' => 'AlmanacServiceController',
'AlmanacTransaction' => 'PhabricatorApplicationTransaction',
diff --git a/src/applications/almanac/conduit/AlmanacConduitAPIMethod.php b/src/applications/almanac/conduit/AlmanacConduitAPIMethod.php
deleted file mode 100644
--- a/src/applications/almanac/conduit/AlmanacConduitAPIMethod.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-
-abstract class AlmanacConduitAPIMethod extends ConduitAPIMethod {
-
- final public function getApplication() {
- return PhabricatorApplication::getByClass(
- 'PhabricatorAlmanacApplication');
- }
-
- public function getMethodStatus() {
- return self::METHOD_STATUS_DEPRECATED;
- }
-
- public function getMethodStatusDescription() {
- return pht(
- 'Almanac is a prototype application and its APIs are '.
- 'subject to change.');
- }
-
- protected function getServiceDictionary(AlmanacService $service) {
- return array(
- 'id' => (int)$service->getID(),
- 'phid' => $service->getPHID(),
- 'name' => $service->getName(),
- 'uri' => PhabricatorEnv::getProductionURI($service->getURI()),
- 'serviceClass' => $service->getServiceClass(),
- 'properties' => $this->getPropertiesDictionary($service),
- );
- }
-
- protected function getBindingDictionary(AlmanacBinding $binding) {
- return array(
- 'id' => (int)$binding->getID(),
- 'phid' => $binding->getPHID(),
- 'properties' => $this->getPropertiesDictionary($binding),
- 'interface' => $this->getInterfaceDictionary($binding->getInterface()),
- );
- }
-
- protected function getPropertiesDictionary(AlmanacPropertyInterface $obj) {
- $properties = $obj->getAlmanacProperties();
- return (object)mpull($properties, 'getFieldValue', 'getFieldName');
- }
-
- protected function getInterfaceDictionary(AlmanacInterface $interface) {
- return array(
- 'id' => (int)$interface->getID(),
- 'phid' => $interface->getPHID(),
- 'address' => $interface->getAddress(),
- 'port' => (int)$interface->getPort(),
- 'device' => $this->getDeviceDictionary($interface->getDevice()),
- 'network' => $this->getNetworkDictionary($interface->getNetwork()),
- );
- }
-
- protected function getDeviceDictionary(AlmanacDevice $device) {
- return array(
- 'id' => (int)$device->getID(),
- 'phid' => $device->getPHID(),
- 'name' => $device->getName(),
- 'properties' => $this->getPropertiesDictionary($device),
- );
- }
-
- protected function getNetworkDictionary(AlmanacNetwork $network) {
- return array(
- 'id' => (int)$network->getID(),
- 'phid' => $network->getPHID(),
- 'name' => $network->getName(),
- );
- }
-
-}
diff --git a/src/applications/almanac/conduit/AlmanacQueryDevicesConduitAPIMethod.php b/src/applications/almanac/conduit/AlmanacQueryDevicesConduitAPIMethod.php
deleted file mode 100644
--- a/src/applications/almanac/conduit/AlmanacQueryDevicesConduitAPIMethod.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-
-final class AlmanacQueryDevicesConduitAPIMethod
- extends AlmanacConduitAPIMethod {
-
- public function getAPIMethodName() {
- return 'almanac.querydevices';
- }
-
- public function getMethodDescription() {
- return pht('Query Almanac devices.');
- }
-
- protected function defineParamTypes() {
- return array(
- 'ids' => 'optional list<id>',
- 'phids' => 'optional list<phid>',
- 'names' => 'optional list<phid>',
- ) + self::getPagerParamTypes();
- }
-
- protected function defineReturnType() {
- return 'list<wild>';
- }
-
- protected function execute(ConduitAPIRequest $request) {
- $viewer = $request->getUser();
-
- $query = id(new AlmanacDeviceQuery())
- ->setViewer($viewer);
-
- $ids = $request->getValue('ids');
- if ($ids !== null) {
- $query->withIDs($ids);
- }
-
- $phids = $request->getValue('phids');
- if ($phids !== null) {
- $query->withPHIDs($phids);
- }
-
- $names = $request->getValue('names');
- if ($names !== null) {
- $query->withNames($names);
- }
-
- $pager = $this->newPager($request);
-
- $devices = $query->executeWithCursorPager($pager);
-
- $data = array();
- foreach ($devices as $device) {
- $data[] = $this->getDeviceDictionary($device);
- }
-
- $results = array(
- 'data' => $data,
- );
-
- return $this->addPagerResults($results, $pager);
- }
-
-}
diff --git a/src/applications/almanac/conduit/AlmanacQueryServicesConduitAPIMethod.php b/src/applications/almanac/conduit/AlmanacQueryServicesConduitAPIMethod.php
deleted file mode 100644
--- a/src/applications/almanac/conduit/AlmanacQueryServicesConduitAPIMethod.php
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-
-final class AlmanacQueryServicesConduitAPIMethod
- extends AlmanacConduitAPIMethod {
-
- public function getAPIMethodName() {
- return 'almanac.queryservices';
- }
-
- public function getMethodDescription() {
- return pht('Query Almanac services.');
- }
-
- protected function defineParamTypes() {
- return array(
- 'ids' => 'optional list<id>',
- 'phids' => 'optional list<phid>',
- 'names' => 'optional list<phid>',
- 'devicePHIDs' => 'optional list<phid>',
- 'serviceClasses' => 'optional list<string>',
- ) + self::getPagerParamTypes();
- }
-
- protected function defineReturnType() {
- return 'list<wild>';
- }
-
- protected function execute(ConduitAPIRequest $request) {
- $viewer = $request->getUser();
-
- $query = id(new AlmanacServiceQuery())
- ->setViewer($viewer)
- ->needBindings(true);
-
- $ids = $request->getValue('ids');
- if ($ids !== null) {
- $query->withIDs($ids);
- }
-
- $phids = $request->getValue('phids');
- if ($phids !== null) {
- $query->withPHIDs($phids);
- }
-
- $names = $request->getValue('names');
- if ($names !== null) {
- $query->withNames($names);
- }
-
- $classes = $request->getValue('serviceClasses');
- if ($classes !== null) {
- $query->withServiceClasses($classes);
- }
-
- $device_phids = $request->getValue('devicePHIDs');
- if ($device_phids !== null) {
- $query->withDevicePHIDs($device_phids);
- }
-
- $pager = $this->newPager($request);
-
- $services = $query->executeWithCursorPager($pager);
-
- $data = array();
- foreach ($services as $service) {
- $phid = $service->getPHID();
-
- $service_bindings = $service->getBindings();
- $service_bindings = array_values($service_bindings);
- foreach ($service_bindings as $key => $service_binding) {
- $service_bindings[$key] = $this->getBindingDictionary($service_binding);
- }
-
- $data[] = $this->getServiceDictionary($service) + array(
- 'bindings' => $service_bindings,
- );
- }
-
- $results = array(
- 'data' => $data,
- );
-
- return $this->addPagerResults($results, $pager);
- }
-
-}
diff --git a/src/applications/almanac/controller/AlmanacServiceEditController.php b/src/applications/almanac/controller/AlmanacServiceEditController.php
--- a/src/applications/almanac/controller/AlmanacServiceEditController.php
+++ b/src/applications/almanac/controller/AlmanacServiceEditController.php
@@ -34,21 +34,19 @@
$this->requireApplicationCapability(
AlmanacCreateServicesCapability::CAPABILITY);
- $service_class = $request->getStr('serviceClass');
- $service_types = AlmanacServiceType::getAllServiceTypes();
- if (empty($service_types[$service_class])) {
- return $this->buildServiceTypeResponse($service_types, $cancel_uri);
+ $service_type = $request->getStr('serviceType');
+
+ try {
+ $service = AlmanacService::initializeNewService($service_type);
+ } catch (Exception $ex) {
+ return $this->buildServiceTypeResponse($cancel_uri);
}
- $service_type = $service_types[$service_class];
- if ($service_type->isClusterServiceType()) {
+ if ($service->isClusterService()) {
$this->requireApplicationCapability(
AlmanacManageClusterServicesCapability::CAPABILITY);
}
- $service = AlmanacService::initializeNewService();
- $service->setServiceClass($service_class);
- $service->attachServiceType($service_type);
$is_new = true;
$title = pht('Create Service');
@@ -125,7 +123,7 @@
$form = id(new AphrontFormView())
->setUser($viewer)
->addHiddenInput('edit', true)
- ->addHiddenInput('serviceClass', $service->getServiceClass())
+ ->addHiddenInput('serviceType', $service->getServiceType())
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Name'))
@@ -177,7 +175,9 @@
));
}
- private function buildServiceTypeResponse(array $service_types, $cancel_uri) {
+ private function buildServiceTypeResponse($cancel_uri) {
+ $service_types = AlmanacServiceType::getAllServiceTypes();
+
$request = $this->getRequest();
$viewer = $this->getViewer();
@@ -197,7 +197,7 @@
$type_control = id(new AphrontFormRadioButtonControl())
->setLabel(pht('Service Type'))
- ->setName('serviceClass')
+ ->setName('serviceType')
->setError($e_service);
foreach ($service_types as $service_type) {
@@ -211,7 +211,7 @@
}
$type_control->addButton(
- get_class($service_type),
+ $service_type->getServiceTypeConstant(),
$service_type->getServiceTypeName(),
array(
$service_type->getServiceTypeDescription(),
diff --git a/src/applications/almanac/controller/AlmanacServiceViewController.php b/src/applications/almanac/controller/AlmanacServiceViewController.php
--- a/src/applications/almanac/controller/AlmanacServiceViewController.php
+++ b/src/applications/almanac/controller/AlmanacServiceViewController.php
@@ -76,7 +76,7 @@
$properties->addProperty(
pht('Service Type'),
- $service->getServiceType()->getServiceTypeShortName());
+ $service->getServiceImplementation()->getServiceTypeShortName());
return $properties;
}
diff --git a/src/applications/almanac/query/AlmanacServiceQuery.php b/src/applications/almanac/query/AlmanacServiceQuery.php
--- a/src/applications/almanac/query/AlmanacServiceQuery.php
+++ b/src/applications/almanac/query/AlmanacServiceQuery.php
@@ -6,7 +6,7 @@
private $ids;
private $phids;
private $names;
- private $serviceClasses;
+ private $serviceTypes;
private $devicePHIDs;
private $namePrefix;
private $nameSuffix;
@@ -28,8 +28,8 @@
return $this;
}
- public function withServiceClasses(array $classes) {
- $this->serviceClasses = $classes;
+ public function withServiceTypes(array $types) {
+ $this->serviceTypes = $types;
return $this;
}
@@ -109,11 +109,11 @@
$hashes);
}
- if ($this->serviceClasses !== null) {
+ if ($this->serviceTypes !== null) {
$where[] = qsprintf(
$conn,
- 'service.serviceClass IN (%Ls)',
- $this->serviceClasses);
+ 'service.serviceType IN (%Ls)',
+ $this->serviceTypes);
}
if ($this->devicePHIDs !== null) {
@@ -141,17 +141,19 @@
}
protected function willFilterPage(array $services) {
- $service_types = AlmanacServiceType::getAllServiceTypes();
+ $service_map = AlmanacServiceType::getAllServiceTypes();
foreach ($services as $key => $service) {
- $service_class = $service->getServiceClass();
- $service_type = idx($service_types, $service_class);
- if (!$service_type) {
+ $implementation = idx($service_map, $service->getServiceType());
+
+ if (!$implementation) {
$this->didRejectResult($service);
unset($services[$key]);
continue;
}
- $service->attachServiceType($service_type);
+
+ $implementation = clone $implementation;
+ $service->attachServiceImplementation($implementation);
}
return $services;
diff --git a/src/applications/almanac/query/AlmanacServiceSearchEngine.php b/src/applications/almanac/query/AlmanacServiceSearchEngine.php
--- a/src/applications/almanac/query/AlmanacServiceSearchEngine.php
+++ b/src/applications/almanac/query/AlmanacServiceSearchEngine.php
@@ -16,7 +16,7 @@
}
public function newResultObject() {
- return AlmanacService::initializeNewService();
+ return new AlmanacService();
}
protected function buildQueryFromParameters(array $map) {
@@ -34,6 +34,10 @@
$query->withDevicePHIDs($map['devicePHIDs']);
}
+ if ($map['serviceTypes']) {
+ $query->withServiceTypes($map['serviceTypes']);
+ }
+
return $query;
}
@@ -48,6 +52,11 @@
->setLabel(pht('Exact Names'))
->setKey('names')
->setDescription(pht('Search for services with specific names.')),
+ id(new PhabricatorSearchDatasourceField())
+ ->setLabel(pht('Service Types'))
+ ->setKey('serviceTypes')
+ ->setDescription(pht('Find services by type.'))
+ ->setDatasource(id(new AlmanacServiceTypeDatasource())),
id(new PhabricatorPHIDsSearchField())
->setLabel(pht('Devices'))
->setKey('devicePHIDs')
@@ -98,8 +107,8 @@
->setHref($service->getURI())
->setObject($service)
->addIcon(
- $service->getServiceType()->getServiceTypeIcon(),
- $service->getServiceType()->getServiceTypeShortName());
+ $service->getServiceImplementation()->getServiceTypeIcon(),
+ $service->getServiceImplementation()->getServiceTypeShortName());
$list->addItem($item);
}
diff --git a/src/applications/almanac/servicetype/AlmanacClusterDatabaseServiceType.php b/src/applications/almanac/servicetype/AlmanacClusterDatabaseServiceType.php
--- a/src/applications/almanac/servicetype/AlmanacClusterDatabaseServiceType.php
+++ b/src/applications/almanac/servicetype/AlmanacClusterDatabaseServiceType.php
@@ -3,6 +3,8 @@
final class AlmanacClusterDatabaseServiceType
extends AlmanacClusterServiceType {
+ const SERVICETYPE = 'cluster.database';
+
public function getServiceTypeShortName() {
return pht('Cluster Database');
}
diff --git a/src/applications/almanac/servicetype/AlmanacClusterRepositoryServiceType.php b/src/applications/almanac/servicetype/AlmanacClusterRepositoryServiceType.php
--- a/src/applications/almanac/servicetype/AlmanacClusterRepositoryServiceType.php
+++ b/src/applications/almanac/servicetype/AlmanacClusterRepositoryServiceType.php
@@ -3,6 +3,8 @@
final class AlmanacClusterRepositoryServiceType
extends AlmanacClusterServiceType {
+ const SERVICETYPE = 'cluster.repository';
+
public function getServiceTypeShortName() {
return pht('Cluster Repository');
}
diff --git a/src/applications/almanac/servicetype/AlmanacCustomServiceType.php b/src/applications/almanac/servicetype/AlmanacCustomServiceType.php
--- a/src/applications/almanac/servicetype/AlmanacCustomServiceType.php
+++ b/src/applications/almanac/servicetype/AlmanacCustomServiceType.php
@@ -2,6 +2,8 @@
final class AlmanacCustomServiceType extends AlmanacServiceType {
+ const SERVICETYPE = 'almanac.custom';
+
public function getServiceTypeShortName() {
return pht('Custom');
}
diff --git a/src/applications/almanac/servicetype/AlmanacDrydockPoolServiceType.php b/src/applications/almanac/servicetype/AlmanacDrydockPoolServiceType.php
--- a/src/applications/almanac/servicetype/AlmanacDrydockPoolServiceType.php
+++ b/src/applications/almanac/servicetype/AlmanacDrydockPoolServiceType.php
@@ -2,6 +2,8 @@
final class AlmanacDrydockPoolServiceType extends AlmanacServiceType {
+ const SERVICETYPE = 'drydock.pool';
+
public function getServiceTypeShortName() {
return pht('Drydock Pool');
}
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
@@ -30,6 +30,11 @@
abstract public function getServiceTypeDescription();
+ final public function getServiceTypeConstant() {
+ return $this->getPhobjectClassConstant('SERVICETYPE', 64);
+ }
+
+
public function getServiceTypeIcon() {
return 'fa-cog';
}
@@ -38,7 +43,7 @@
* Return `true` if this service type is a Phabricator cluster service type.
*
* These special services change the behavior of Phabricator, and require
- * elevated permission to create.
+ * elevated permission to create and edit.
*
* @return bool True if this is a Phabricator cluster service type.
*/
@@ -63,6 +68,7 @@
public static function getAllServiceTypes() {
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getServiceTypeConstant')
->setSortMethod('getServiceTypeName')
->execute();
}
diff --git a/src/applications/almanac/storage/AlmanacService.php b/src/applications/almanac/storage/AlmanacService.php
--- a/src/applications/almanac/storage/AlmanacService.php
+++ b/src/applications/almanac/storage/AlmanacService.php
@@ -17,17 +17,29 @@
protected $mailKey;
protected $viewPolicy;
protected $editPolicy;
- protected $serviceClass;
+ protected $serviceType;
private $almanacProperties = self::ATTACHABLE;
private $bindings = self::ATTACHABLE;
- private $serviceType = self::ATTACHABLE;
+ private $serviceImplementation = self::ATTACHABLE;
+
+ public static function initializeNewService($type) {
+ $type_map = AlmanacServiceType::getAllServiceTypes();
+
+ $implementation = idx($type_map, $type);
+ if (!$implementation) {
+ throw new Exception(
+ pht(
+ 'No Almanac service type "%s" exists!',
+ $type));
+ }
- public static function initializeNewService() {
return id(new AlmanacService())
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
->setEditPolicy(PhabricatorPolicies::POLICY_ADMIN)
- ->attachAlmanacProperties(array());
+ ->attachAlmanacProperties(array())
+ ->setServiceType($type)
+ ->attachServiceImplementation($implementation);
}
protected function getConfiguration() {
@@ -37,7 +49,7 @@
'name' => 'text128',
'nameIndex' => 'bytes12',
'mailKey' => 'bytes20',
- 'serviceClass' => 'text64',
+ 'serviceType' => 'text64',
),
self::CONFIG_KEY_SCHEMA => array(
'key_name' => array(
@@ -47,8 +59,8 @@
'key_nametext' => array(
'columns' => array('name'),
),
- 'key_class' => array(
- 'columns' => array('serviceClass'),
+ 'key_servicetype' => array(
+ 'columns' => array('serviceType'),
),
),
) + parent::getConfiguration();
@@ -83,17 +95,17 @@
return $this;
}
- public function getServiceType() {
- return $this->assertAttached($this->serviceType);
+ public function getServiceImplementation() {
+ return $this->assertAttached($this->serviceImplementation);
}
- public function attachServiceType(AlmanacServiceType $type) {
- $this->serviceType = $type;
+ public function attachServiceImplementation(AlmanacServiceType $type) {
+ $this->serviceImplementation = $type;
return $this;
}
public function isClusterService() {
- return $this->getServiceType()->isClusterServiceType();
+ return $this->getServiceImplementation()->isClusterServiceType();
}
@@ -128,7 +140,7 @@
}
public function getAlmanacPropertyFieldSpecifications() {
- return $this->getServiceType()->getFieldSpecifications();
+ return $this->getServiceImplementation()->getFieldSpecifications();
}
public function newAlmanacPropertyEditEngine() {
diff --git a/src/applications/almanac/typeahead/AlmanacServiceDatasource.php b/src/applications/almanac/typeahead/AlmanacServiceDatasource.php
--- a/src/applications/almanac/typeahead/AlmanacServiceDatasource.php
+++ b/src/applications/almanac/typeahead/AlmanacServiceDatasource.php
@@ -28,9 +28,9 @@
// selected, or show all services but mark the invalid ones disabled and
// prevent their selection.
- $service_classes = $this->getParameter('serviceClasses');
- if ($service_classes) {
- $services->withServiceClasses($service_classes);
+ $service_types = $this->getParameter('serviceTypes');
+ if ($service_types) {
+ $services->withServiceTypes($service_types);
}
$services = $this->executeQuery($services);
diff --git a/src/applications/almanac/typeahead/AlmanacServiceTypeDatasource.php b/src/applications/almanac/typeahead/AlmanacServiceTypeDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/almanac/typeahead/AlmanacServiceTypeDatasource.php
@@ -0,0 +1,43 @@
+<?php
+
+final class AlmanacServiceTypeDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getBrowseTitle() {
+ return pht('Browse Service Types');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type a service type name...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorAlmanacApplication';
+ }
+
+ public function loadResults() {
+ $results = $this->buildResults();
+ return $this->filterResultsAgainstTokens($results);
+ }
+
+ protected function renderSpecialTokens(array $values) {
+ return $this->renderTokensFromResults($this->buildResults(), $values);
+ }
+
+ private function buildResults() {
+ $results = array();
+
+ $types = AlmanacServiceType::getAllServiceTypes();
+
+ $results = array();
+ foreach ($types as $key => $type) {
+ $results[$key] = id(new PhabricatorTypeaheadResult())
+ ->setName($type->getServiceTypeName())
+ ->setIcon($type->getServiceTypeIcon())
+ ->setPHID($key);
+ }
+
+ return $results;
+ }
+
+}
diff --git a/src/applications/config/check/PhabricatorRepositoriesSetupCheck.php b/src/applications/config/check/PhabricatorRepositoriesSetupCheck.php
--- a/src/applications/config/check/PhabricatorRepositoriesSetupCheck.php
+++ b/src/applications/config/check/PhabricatorRepositoriesSetupCheck.php
@@ -10,9 +10,9 @@
$cluster_services = id(new AlmanacServiceQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
- ->withServiceClasses(
+ ->withServiceTypes(
array(
- 'AlmanacClusterRepositoryServiceType',
+ AlmanacClusterRepositoryServiceType::SERVICETYPE,
))
->setLimit(1)
->execute();
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php b/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php
@@ -47,9 +47,9 @@
// allocations, we fail.
$services = id(new AlmanacServiceQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
- ->withServiceClasses(
+ ->withServiceTypes(
array(
- 'AlmanacClusterRepositoryServiceType',
+ AlmanacClusterRepositoryServiceType::SERVICETYPE,
))
->needProperties(true)
->execute();
diff --git a/src/applications/drydock/blueprint/DrydockAlmanacServiceHostBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockAlmanacServiceHostBlueprintImplementation.php
--- a/src/applications/drydock/blueprint/DrydockAlmanacServiceHostBlueprintImplementation.php
+++ b/src/applications/drydock/blueprint/DrydockAlmanacServiceHostBlueprintImplementation.php
@@ -184,7 +184,7 @@
'type' => 'datasource',
'datasource.class' => 'AlmanacServiceDatasource',
'datasource.parameters' => array(
- 'serviceClasses' => $this->getAlmanacServiceClasses(),
+ 'serviceTypes' => $this->getAlmanacServiceTypes(),
),
'required' => true,
),
@@ -213,7 +213,7 @@
$services = id(new AlmanacServiceQuery())
->setViewer($viewer)
->withPHIDs($service_phids)
- ->withServiceClasses($this->getAlmanacServiceClasses())
+ ->withServiceTypes($this->getAlmanacServiceTypes())
->needBindings(true)
->execute();
$services = mpull($services, null, 'getPHID');
@@ -283,9 +283,9 @@
return $this->freeBindings;
}
- private function getAlmanacServiceClasses() {
+ private function getAlmanacServiceTypes() {
return array(
- 'AlmanacDrydockPoolServiceType',
+ AlmanacDrydockPoolServiceType::SERVICETYPE,
);
}
diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php
--- a/src/applications/repository/storage/PhabricatorRepository.php
+++ b/src/applications/repository/storage/PhabricatorRepository.php
@@ -2047,7 +2047,7 @@
'be loaded.'));
}
- $service_type = $service->getServiceType();
+ $service_type = $service->getServiceImplementation();
if (!($service_type instanceof AlmanacClusterRepositoryServiceType)) {
throw new Exception(
pht(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Feb 25, 12:03 PM (9 h, 3 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7200896
Default Alt Text
D15346.id37005.diff (29 KB)
Attached To
Mode
D15346: Store Almanac "service types" instead of "service classes"
Attached
Detach File
Event Timeline
Log In to Comment