Example #1
0
 /**
  * Takes the current request and supplements it with the service's defaults
  * to merge them into a complete request.
  */
 protected function supplementRequestWithDefaults()
 {
     // properties to set only if they are empty
     if (empty($this->request->getLocation())) {
         $this->request->setLocation($this->defaults->getLocation());
     }
     if (empty($this->request->getMethod())) {
         $this->request->setMethod($this->defaults->getMethod());
     }
     if (empty($this->request->getParameters())) {
         $this->request->setParameters($this->defaults->getParameters());
     }
     if (empty($this->request->getBody())) {
         $this->request->setBody($this->defaults->getBody());
     }
     if ($this->credentialsAreEmpty($this->request->getCredentials()) && !$this->credentialsAreEmpty($this->defaults->getCredentials())) {
         $this->request->setCredentials($this->defaults->getCredentials()['name'], $this->defaults->getCredentials()['password'], $this->defaults->getCredentials()['domain']);
     }
     // properties to expand
     if (!empty($this->defaults->getHeaders())) {
         $this->request->setHeaders(array_merge($this->request->getHeaders(), $this->defaults->getHeaders()));
     }
 }