Exemplo n.º 1
0
 /**
  * Constructor.
  *
  * @param string                   $wsdl       URI of the WSDL file
  * @param EventDispatcherInterface $dispatcher The event dispatcher
  * @param User                     $user       The profile
  * @param array                    $options    The options
  */
 public function __construct($wsdl, EventDispatcherInterface $dispatcher, User $user, array $options = array())
 {
     $defaults = array('soap_version' => SOAP_1_1, 'encoding' => 'UTF-8', 'trace' => true, 'exception' => true, 'cache_wsdl' => WSDL_CACHE_BOTH, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS);
     parent::__construct($wsdl, $options + $user->getSoapOptions() + $defaults);
     $this->dispatcher = $dispatcher;
     $this->user = $user;
 }
Exemplo n.º 2
0
 /**
  * Gets the semaphore for given profile.
  *
  * @param User $user The profile
  *
  * @return Semaphore
  */
 private function getSemaphore(User $user)
 {
     $key = 'api_' . $user->getHashCode();
     if (!isset($this->semaphores[$key])) {
         $this->semaphores[$key] = $this->factory->createSemaphore($key, $this->limit);
     }
     return $this->semaphores[$key];
 }
Exemplo n.º 3
0
 private function createHttpHeaders(User $user)
 {
     $headers = array('Authorization: Bearer ' . $user->getAccessToken(), 'Accept-Language: ' . $user->getLocale());
     if ($user->getLogin() !== null) {
         $headers[] = 'Client-Login: ' . $user->getLogin();
     }
     return join("\r\n", $headers);
 }