Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/controller/AlmanacServiceEditController.php
Show All 37 Lines | if ($id) { | ||||
$service_types = AlmanacServiceType::getAllServiceTypes(); | $service_types = AlmanacServiceType::getAllServiceTypes(); | ||||
if (empty($service_types[$service_class])) { | if (empty($service_types[$service_class])) { | ||||
return $this->buildServiceTypeResponse($service_types, $cancel_uri); | return $this->buildServiceTypeResponse($service_types, $cancel_uri); | ||||
} | } | ||||
$service_type = $service_types[$service_class]; | $service_type = $service_types[$service_class]; | ||||
if ($service_type->isClusterServiceType()) { | if ($service_type->isClusterServiceType()) { | ||||
$this->requireApplicationCapability( | $this->requireApplicationCapability( | ||||
AlmanacCreateClusterServicesCapability::CAPABILITY); | AlmanacManageClusterServicesCapability::CAPABILITY); | ||||
} | } | ||||
$service = AlmanacService::initializeNewService(); | $service = AlmanacService::initializeNewService(); | ||||
$service->setServiceClass($service_class); | $service->setServiceClass($service_class); | ||||
$service->attachServiceType($service_type); | $service->attachServiceType($service_type); | ||||
$is_new = true; | $is_new = true; | ||||
$title = pht('Create Service'); | $title = pht('Create Service'); | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | private function buildServiceTypeResponse(array $service_types, $cancel_uri) { | ||||
$errors = array(); | $errors = array(); | ||||
if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
$e_service = pht('Required'); | $e_service = pht('Required'); | ||||
$errors[] = pht( | $errors[] = pht( | ||||
'To create a new service, you must select a service type.'); | 'To create a new service, you must select a service type.'); | ||||
} | } | ||||
list($can_cluster, $cluster_link) = $this->explainApplicationCapability( | list($can_cluster, $cluster_link) = $this->explainApplicationCapability( | ||||
AlmanacCreateClusterServicesCapability::CAPABILITY, | AlmanacManageClusterServicesCapability::CAPABILITY, | ||||
pht('You have permission to create cluster services.'), | pht('You have permission to create cluster services.'), | ||||
pht('You do not have permission to create new cluster services.')); | pht('You do not have permission to create new cluster services.')); | ||||
$type_control = id(new AphrontFormRadioButtonControl()) | $type_control = id(new AphrontFormRadioButtonControl()) | ||||
->setLabel(pht('Service Type')) | ->setLabel(pht('Service Type')) | ||||
->setName('serviceClass') | ->setName('serviceClass') | ||||
->setError($e_service); | ->setError($e_service); | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |