/**
  * Get a repository connected to the jackrabbit backend specified in the
  * parameters.
  *
  * {@inheritDoc}
  *
  * Jackrabbit repositories have no default repository, passing null as
  * parameters will always return null.
  *
  * @api
  */
 public function getRepository(array $parameters = null)
 {
     if (null === $parameters) {
         throw new ConfigurationException('Jackalope-jackrabbit needs parameters');
     }
     // check if we have all required parameters
     if (count(array_diff_key(self::$required, $parameters))) {
         throw new ConfigurationException('A required parameter is missing: ' . implode(', ', array_keys(array_diff_key(self::$required, $parameters))));
     }
     // check if we have any unknown parameters
     if (count(array_diff_key($parameters, self::$required, self::$optional))) {
         throw new ConfigurationException('Additional unknown parameters found: ' . implode(', ', array_keys(array_diff_key($parameters, self::$required, self::$optional))));
     }
     if (isset($parameters['jackalope.factory'])) {
         $factory = $parameters['jackalope.factory'] instanceof FactoryInterface ? $parameters['jackalope.factory'] : new $parameters['jackalope.factory']();
     } else {
         $factory = new Jackrabbit\Factory();
     }
     $uri = $parameters['jackalope.jackrabbit_uri'];
     if ('/' !== substr($uri, -1, 1)) {
         $uri .= '/';
     }
     $transport = $factory->get('Transport\\Jackrabbit\\Client', array($uri));
     if (isset($parameters['jackalope.default_header'])) {
         $transport->addDefaultHeader($parameters['jackalope.default_header']);
     }
     if (isset($parameters['jackalope.jackrabbit_expect'])) {
         $transport->sendExpect($parameters['jackalope.jackrabbit_expect']);
     }
     if (isset($parameters['jackalope.check_login_on_server'])) {
         $transport->setCheckLoginOnServer($parameters['jackalope.check_login_on_server']);
     }
     if (isset($parameters['jackalope.logger'])) {
         $transport = $factory->get('Transport\\Jackrabbit\\LoggingClient', array($transport, $parameters['jackalope.logger']));
     }
     $curlOptions = array_key_exists('jackalope.jackrabbit_curl_options', $parameters) ? $parameters['jackalope.jackrabbit_curl_options'] : array();
     if (isset($parameters['jackalope.jackrabbit_force_http_version_10'])) {
         $curlOptions[CURLOPT_HTTP_VERSION] = true;
     }
     if (count($curlOptions)) {
         $transport->addCurlOptions($curlOptions);
     }
     $options['stream_wrapper'] = empty($parameters['jackalope.disable_stream_wrapper']);
     if (isset($parameters[Session::OPTION_AUTO_LASTMODIFIED])) {
         $options[Session::OPTION_AUTO_LASTMODIFIED] = $parameters[Session::OPTION_AUTO_LASTMODIFIED];
     }
     return new Repository($factory, $transport, $options);
 }
 /**
  * Get a repository connected to the jackrabbit backend specified in the
  * parameters.
  *
  * {@inheritDoc}
  *
  * Jackrabbit repositories have no default repository, passing null as
  * parameters will always return null.
  *
  * @api
  */
 public function getRepository(array $parameters = null)
 {
     if (null === $parameters) {
         return null;
     }
     // check if we have all required keys
     $present = array_intersect_key(self::$required, $parameters);
     if (count(array_diff_key(self::$required, $present))) {
         return null;
     }
     $defined = array_intersect_key(array_merge(self::$required, self::$optional), $parameters);
     if (count(array_diff_key($defined, $parameters))) {
         return null;
     }
     if (isset($parameters['jackalope.factory'])) {
         $factory = $parameters['jackalope.factory'] instanceof FactoryInterface ? $parameters['jackalope.factory'] : new $parameters['jackalope.factory']();
     } else {
         $factory = new Jackrabbit\Factory();
     }
     $uri = $parameters['jackalope.jackrabbit_uri'];
     if ('/' !== substr($uri, -1, 1)) {
         $uri .= '/';
     }
     $transport = $factory->get('Transport\\Jackrabbit\\Client', array($uri));
     if (isset($parameters['jackalope.default_header'])) {
         $transport->addDefaultHeader($parameters['jackalope.default_header']);
     }
     if (isset($parameters['jackalope.jackrabbit_expect'])) {
         $transport->sendExpect($parameters['jackalope.jackrabbit_expect']);
     }
     if (isset($parameters['jackalope.check_login_on_server'])) {
         $transport->setCheckLoginOnServer($parameters['jackalope.check_login_on_server']);
     }
     if (isset($parameters['jackalope.logger'])) {
         $transport = $factory->get('Transport\\Jackrabbit\\LoggingClient', array($transport, $parameters['jackalope.logger']));
     }
     $options['stream_wrapper'] = empty($parameters['jackalope.disable_stream_wrapper']);
     if (isset($parameters[Session::OPTION_AUTO_LASTMODIFIED])) {
         $options[Session::OPTION_AUTO_LASTMODIFIED] = $parameters[Session::OPTION_AUTO_LASTMODIFIED];
     }
     return new Repository($factory, $transport, $options);
 }