Beispiel #1
0
 /**
  * Производит конфигурирование сервиса
  *
  * @param array $config Опции конфигурации
  *
  * @throws ConfigurationErrorException
  */
 public function configure(array $config = [])
 {
     if (!array_key_exists('url', $config)) {
         throw new ConfigurationErrorException(self::ERR__URL_REQUIRED);
     }
     $soapOptions = [];
     if (array_key_exists('soapOptions', $config)) {
         $soapOptions = $config['soapOptions'];
     }
     $this->client = new Client($config['url'], $soapOptions);
     if (array_key_exists('contentType', $config)) {
         $this->client->setContentType($config['contentType']);
     }
     if (array_key_exists('curlOptions', $config)) {
         $this->client->setCurlOptions($config['curlOptions']);
     }
     if (array_key_exists('defaultArgs', $config)) {
         if (!is_array($config['defaultArgs'])) {
             throw new ConfigurationErrorException(self::ERR__DEFAULT_ARGS_ARRAY);
         }
         $this->defaultArgs = $config['defaultArgs'];
     }
     $this->mapper = new Mapper();
     if (array_key_exists('mapper', $config)) {
         $this->mapper->setConfig($config['mapper']);
     }
     if (!array_key_exists('pinba', $config)) {
         $config['pinba'] = ['type' => 'soap', 'target' => $config['url']];
     }
     parent::configure($config);
 }
 /**
  * Инициализирует компонент
  * @return void
  */
 public function init()
 {
     $this->instance = new $this->service();
     $this->instance->configure($this->options);
 }
Beispiel #3
0
 /**
  * Производит конфигурирование сервиса
  *
  * @param array $config Опции конфигурации
  *
  * @throws ConfigurationErrorException
  * @throws ErrorException
  */
 public function configure(array $config = [])
 {
     if (!array_key_exists('host', $config)) {
         throw new ConfigurationErrorException(self::ERR__HOST_REQUIRED);
     }
     if (array_key_exists('port', $config) && is_numeric($config['port'])) {
         $this->port = $config['port'];
     }
     if (array_key_exists('readOnly', $config)) {
         $this->readOnly = filter_var($config['readOnly'], FILTER_VALIDATE_BOOLEAN);
     }
     if (!$this->readOnly) {
         if (!array_key_exists('login', $config)) {
             throw new ConfigurationErrorException(self::ERR__LOGIN_REQUIRED);
         }
         if (!array_key_exists('password', $config)) {
             throw new ConfigurationErrorException(self::ERR__PASSWORD_REQUIRED);
         }
     }
     $this->client = ldap_connect($config['host'], $this->port);
     if (!$this->client) {
         throw new ErrorException(self::ERR__AD_CONNECT);
     }
     if ($this->readOnly) {
         $bind = ldap_bind($this->client);
     } else {
         $bind = ldap_bind($this->client, $config['login'], $config['password']);
     }
     if (!$bind) {
         $this->client = false;
         throw new ErrorException(self::ERR__AD_BIND);
     }
     if (!array_key_exists('pinba', $config)) {
         $config['pinba'] = ['type' => 'ldap', 'target' => $config['host']];
     }
     parent::configure($config);
 }