/** * @param Configuration $configuration * @return void */ public function initialize(Configuration $configuration) { // start up the service locator $this->container = new Container(); foreach ($this->default_components as $k => $v) { if ($k == 'parser.login' and $configuration->getRetsVersion()->isAtLeast1_8()) { $v = '\\PHRETS\\Parsers\\Login\\OneEight'; } $this->container->singleton($k, function () use($v) { return new $v(); }); } }
public function __construct(Configuration $configuration) { // save the configuration along with this session $this->configuration = $configuration; // start up our Guzzle HTTP client $this->default_options = ['auth' => [$configuration->getUsername(), $configuration->getPassword(), $configuration->getHttpAuthenticationMethod()], 'headers' => ['User-Agent' => $configuration->getUserAgent(), 'RETS-Version' => $configuration->getRetsVersion()->asHeader(), 'Accept-Encoding' => 'gzip', 'Accept' => '*/*']]; if ($this->configuration->readOption('disable_follow_location')) { $this->default_options['allow_redirects'] = false; } $this->cookie_jar = new CookieJar(); $this->client = PHRETSClient::make(); // start up the Capabilities tracker and add Login as the first one $this->capabilities = new Capabilities(); $this->capabilities->add('Login', $configuration->getLoginUrl()); }
public function __construct(Configuration $configuration) { // save the configuration along with this session $this->configuration = $configuration; // start up our Guzzle HTTP client $this->client = PHRETSClient::make(); $this->cookie_jar = new CookieJar(); // set the authentication as defaults to use for the entire client $this->client->setDefaultOption('auth', [$configuration->getUsername(), $configuration->getPassword(), $configuration->getHttpAuthenticationMethod()]); $this->client->setDefaultOption('headers', ['User-Agent' => $configuration->getUserAgent(), 'RETS-Version' => $configuration->getRetsVersion()->asHeader(), 'Accept-Encoding' => 'gzip']); // disable following 'Location' header (redirects) automatically if ($this->configuration->readOption('disable_follow_location')) { $this->client->setDefaultOption('allow_redirects', false); } // start up the Capabilities tracker and add Login as the first one $this->capabilities = new Capabilities(); $this->capabilities->add('Login', $configuration->getLoginUrl()); }
/** @test **/ public function it_handles_versions_correctly() { $config = new Configuration(); $config->setRetsVersion('1.7.2'); $this->assertInstanceOf('PHRETS\\Versions\\RETSVersion', $config->getRetsVersion()); }