Example #1
0
 /**
  * @internal
  */
 public function __construct(Configuration $configuration, $data)
 {
     if (!isset($data['query_string'])) {
         throw new \RuntimeException('The data returned by the signing API are not valid.');
     }
     if (!isset($data['options'])) {
         $data['options'] = array();
     }
     $data['options']['aggreg_samples'] = $configuration->getSamples();
     if ($configuration->getTitle()) {
         $data['options']['profile_title'] = $configuration->getTitle();
     }
     $data['user_metadata'] = $configuration->getAllMetadata();
     $data['yaml'] = $configuration->toYaml();
     $this->data = $data;
 }
Example #2
0
 private function getRequestDetails(Configuration $config)
 {
     $details = array();
     if ($build = $config->getBuild()) {
         $details['collabToken'] = $build->getEnv();
         // create a job in the current build
         $content = json_encode(array('name' => $config->getTitle()));
         $data = json_decode($this->sendHttpRequest($this->config->getEndpoint() . '/api/v1/build/' . $build->getUuid() . '/jobs', 'POST', array('content' => $content), array('Content-Type: application/json')), true);
         $build->incJob();
         $details['requestId'] = $data['uuid'];
     } else {
         $details['collabToken'] = $this->getEnvUuid($this->config->getEnv());
     }
     $id = self::NO_REFERENCE_ID;
     if ($config->getReference() || $config->isNewReference()) {
         foreach ($collabToken['profileSlots'] as $profileSlot) {
             if ($config->isNewReference() && $profileSlot['empty'] && self::NO_REFERENCE_ID !== $profileSlot['id']) {
                 $id = $profileSlot['id'];
                 break;
             }
             if ($config->getReference() == $profileSlot['number'] || $config->getReference() == $profileSlot['id']) {
                 $id = $profileSlot['id'];
                 break;
             }
         }
         if (self::NO_REFERENCE_ID === $id) {
             throw new Exception\ReferenceNotFoundException(sprintf('Unable to find the "%s" reference.', $config->getReference()));
         }
     }
     $details['profileSlot'] = $id;
     return $details;
 }