/** * Constructor * * @param string $wsdl * @throws Exception * @param array $options */ public function __construct($wsdl, $options = array()) { $options = array_merge(['httpPlayback' => ['mode' => null]], $options); // Verify that a user name and password were entered. if (empty($options['user']) || empty($options['password'])) { throw new Exception('A username and password is required.'); } // Set the username and password properties. $this->user = $options['user']; $this->password = $options['password']; // If a version was set then add it to the headers. if (!empty($options['version'])) { $this->__default_headers[] = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'RequestServerVersion Version="' . $options['version'] . '"'); } // If impersonation was set then add it to the headers. if (!empty($options['impersonation'])) { $this->__default_headers[] = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'ExchangeImpersonation', $options['impersonation']); } if (!empty($options['timezone'])) { $this->__default_headers[] = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'TimeZoneContext', array('TimeZoneDefinition' => array('Id' => $options['timezone']))); unset($options['timezone']); } $this->httpPlayback = HttpPlayback::getInstance($options['httpPlayback']); parent::__construct($wsdl, $options); }
/** * @param mixed $location * @param string $user * @param string $password * @param $wsdl * @param array $options */ public function __construct($location, $auth, $wsdl, $options = array()) { $this->auth = $auth; $options = array_replace_recursive(['httpPlayback' => ['mode' => null]], $options); $options['location'] = $location; // If a version was set then add it to the headers. if (!empty($options['version'])) { $this->__default_headers[] = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'RequestServerVersion Version="' . $options['version'] . '"'); } // If impersonation was set then add it to the headers. if (!empty($options['impersonation'])) { $impersonation = $options['impersonation']; if (is_string($impersonation)) { $impersonation = ExchangeImpersonation::fromEmailAddress($options['impersonation']); } $this->__default_headers[] = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'ExchangeImpersonation', $impersonation->toXmlObject()); } if (!empty($options['timezone'])) { $this->__default_headers[] = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'TimeZoneContext', array('TimeZoneDefinition' => array('Id' => $options['timezone']))); } $this->httpPlayback = HttpPlayback::getInstance($options['httpPlayback']); parent::__construct($wsdl, $options); }