Beispiel #1
0
 /**
  * Set the service description of the client
  *
  * @param ServiceDescription $service       Service description
  * @param bool               $updateFactory Set to false to not update the service description based command factory
  *                                          if it is not already on the client.
  * @return Client
  */
 public function setDescription(ServiceDescription $service, $updateFactory = true)
 {
     $this->serviceDescription = $service;
     // Add the service description factory to the factory chain if it is not set
     if ($updateFactory) {
         // Convert non chain factories to a chain factory
         if (!$this->getCommandFactory() instanceof CompositeFactory) {
             $this->commandFactory = new CompositeFactory(array($this->commandFactory));
         }
         // Add a service description factory if one does not already exist
         if (!$this->commandFactory->has('Guzzle\\Service\\Command\\Factory\\ServiceDescriptionFactory')) {
             // Add the service description factory before the concrete factory
             $this->commandFactory->add(new ServiceDescriptionFactory($service), 'Guzzle\\Service\\Command\\Factory\\ConcreteClassFactory');
         } else {
             // Update an existing service description factory
             $factory = $this->commandFactory->find('Guzzle\\Service\\Command\\Factory\\ServiceDescriptionFactory');
             $factory->setServiceDescription($service);
         }
     }
     // If a baseUrl was set on the description, then update the client
     if ($baseUrl = $service->getBaseUrl()) {
         $this->setBaseUrl($baseUrl);
     }
     return $this;
 }
Beispiel #2
0
 public function setDescription(ServiceDescriptionInterface $service)
 {
     $this->serviceDescription = $service;
     if ($this->getCommandFactory() && $this->getCommandFactory() instanceof CompositeFactory) {
         $this->commandFactory->add(new Command\Factory\ServiceDescriptionFactory($service));
     }
     // If a baseUrl was set on the description, then update the client
     if ($baseUrl = $service->getBaseUrl()) {
         $this->setBaseUrl($baseUrl);
     }
     return $this;
 }