public function __construct(SVNRepositoryConfig $repoConfig, IOInterface $io, Config $config) { // @TODO: add event dispatcher? $this->repoConfig = $repoConfig; $this->plugin = $repoConfig->getPlugin(); // check url immediately - can't do anything without it $urls = []; foreach ((array) $repoConfig->get('url') as $url) { if (($urlParts = parse_url($url)) === false || empty($urlParts['scheme'])) { continue; } // untrailingslashit $urls[] = rtrim($url, '/'); } if (!count($urls)) { throw new \UnexpectedValueException('No valid URLs for SVN repository: ' . print_r($repoConfig->get('url'), true)); } $repoConfig->set('url', $urls); // use the cache TTL from the config? if ($repoConfig->get('cache-ttl') === 'config') { $repoConfig->set('cache-ttl', $config->get('cache-files-ttl')); } $this->io = $io; $this->cache = new Cache($io, $config->get('cache-repo-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', reset($urls))); $this->loader = new ArrayLoader(); // clear out stale cache $this->cache->gc($repoConfig->get('cache-ttl'), $config->get('cache-files-maxsize')); $this->vendors = $repoConfig->get('vendors'); $this->defaultVendor = key($this->vendors); // create an SvnUtil to execute commands $this->svnUtil = new SvnUtil($io, $repoConfig->get('trust-cert')); }