/**
  * Checks if the given source-object pair is valid.
  *
  * @param $value
  *
  * @return bool
  */
 public function validate($value)
 {
     $pairs = $this->pairs;
     $objects = $pairs[$value['source']];
     if (!isset($objects[$value['object']])) {
         $supportedObjects = '';
         foreach ($objects as $object => $i) {
             $supportedObjects .= $object . ' - ' . eventObject($object) . ', ';
         }
         $this->setError(_s('Incorrect event object "%1$s" (%2$s) for event source "%3$s" (%4$s), only the following objects are supported: %5$s.', $value['object'], eventObject($value['object']), $value['source'], eventSource($value['source']), rtrim($supportedObjects, ', ')));
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Validates the input parameters for the get() method.
  *
  * @throws APIException     if the input is invalid
  *
  * @param array     $options
  *
  * @return void
  */
 protected function validateGet(array $options)
 {
     $sourceValidator = new CLimitedSetValidator(array('values' => array_keys(eventSource())));
     if (!$sourceValidator->validate($options['source'])) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect source value.'));
     }
     $objectValidator = new CLimitedSetValidator(array('values' => array_keys(eventObject())));
     if (!$objectValidator->validate($options['object'])) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect object value.'));
     }
     $sourceObjectValidator = new CEventSourceObjectValidator();
     if (!$sourceObjectValidator->validate(array('source' => $options['source'], 'object' => $options['object']))) {
         self::exception(ZBX_API_ERROR_PARAMETERS, $sourceObjectValidator->getError());
     }
 }