Beispiel #1
0
 /**
  * Build the Salesforce SOAP client
  *
  * @throws \UnexpectedValueException
  * @return ClientInterface
  */
 public function getInstance()
 {
     $connectionFactory = new ConnectionFactory();
     $connection = $connectionFactory->getInstance($this->wsdl);
     $cache = $this->cache ? $this->cache : new ArrayCache();
     if ($this->wsdl->getTns() === Wsdl::TNS_ENTERPRISE) {
         $client = new EnterpriseClient($connection, $cache);
     } elseif ($this->wsdl->getTns() === Wsdl::TNS_PARTNER) {
         $client = new PartnerClient($connection, $cache);
     } else {
         throw new \UnexpectedValueException(sprintf('Wsdl with target namespace "%s" not supported.', $this->wsdl->getTns()));
     }
     if ($this->log) {
         $logPlugin = new LogPlugin($this->log);
         $client->getEventDispatcher()->addSubscriber($logPlugin);
     }
     if (null === $client->getLoginResult()) {
         $client->login($this->username, $this->password, $this->token);
     }
     return $client;
 }
Beispiel #2
0
 /**
  * @param Wsdl  $wsdl
  * @param array $options
  */
 public function __construct(Wsdl $wsdl, array $options = array())
 {
     parent::__construct($wsdl->getPathname(), $options);
     $this->wsdl = $wsdl;
 }