Пример #1
0
 public function testGetPrimaryKey()
 {
     $this->assertEquals('service_id', Service::getPrimaryKey());
 }
Пример #2
0
 /**
  * Display the configuration snapshot of a service
  * with template inheritance
  *
  * @method get
  * @route /service/snapshotslide/[i:id]
  */
 public function snapshotslideAction()
 {
     $params = $this->getParams();
     $data = ServiceRepository::getConfigurationData($params['id']);
     $serviceId = Service::getPrimaryKey();
     $serviceDescription = Service::getUniqueLabelField();
     $hostId = Host::getPrimaryKey();
     $hostName = Host::getUniqueLabelField();
     $filters = array($serviceId => $params['id']);
     //If service inherits a template
     if (isset($data['service_template_model_stm_id'])) {
         $data = ServiceRepository::getConfigurationData($data['service_template_model_stm_id']);
     } else {
         $data = ServiceRepository::getConfigurationData($params['id']);
     }
     $list = HostService::getMergedParameters(array($hostId, $hostName), array($serviceId, $serviceDescription), -1, 0, null, "ASC", $filters, "OR");
     foreach ($list as $obj) {
         $data[$serviceDescription] = $obj[$hostName] . '|' . $obj[$serviceDescription];
     }
     $serviceConfiguration = ServiceRepository::formatDataForSlider($data);
     $edit_url = $this->router->getPathFor("/centreon-configuration/service/" . $params['id']);
     $this->router->response()->json(array('serviceConfig' => $serviceConfiguration, 'edit_url' => $edit_url, 'success' => true));
 }
Пример #3
0
 /**
  * Return Service name
  *
  * @param int or array $svcId The service ID
  * @return array
  */
 public static function getName($svcId)
 {
     $di = Di::getDefault();
     $router = $di->get('router');
     $serviceId = Service::getPrimaryKey();
     $serviceDescription = Service::getUniqueLabelField();
     $hostId = Host::getPrimaryKey();
     $hostName = Host::getUniqueLabelField();
     $filters = array($serviceId => $svcId);
     $list = HostServiceRelation::getMergedParameters(array($hostId, $hostName), array($serviceId, $serviceDescription), -1, 0, null, "ASC", $filters, "OR");
     $finalList = array();
     foreach ($list as $obj) {
         $finalList[] = array("id" => $obj[$serviceId], "text" => $obj[$hostName] . ' ' . $obj[$serviceDescription]);
     }
     return $finalList;
 }