/** * Factory for PAIA driver. * * @param ServiceManager $sm Service manager. * * @return PAIA */ public static function getPAIA(ServiceManager $sm) { $paia = new PAIA($sm->getServiceLocator()->get('VuFind\\DateConverter'), $sm->getServiceLocator()->get('VuFind\\SessionManager')); $paia->setCacheStorage($sm->getServiceLocator()->get('VuFind\\CacheManager')->getCache('object')); return $paia; }
/** * Create connector with fixture file. * * @param string $fixture Fixture file * * @return Connector * * @throws InvalidArgumentException Fixture file does not exist */ protected function createConnector($fixture = null) { $adapter = new TestAdapter(); if ($fixture) { $file = realpath(__DIR__ . '/../../../../../../tests/fixtures/paia/response/' . $fixture); if (!is_string($file) || !file_exists($file) || !is_readable($file)) { throw new InvalidArgumentException(sprintf('Unable to load fixture file: %s ', $file)); } $response = file_get_contents($file); $responseObj = HttpResponse::fromString($response); $adapter->setResponse($responseObj); } $service = new \VuFindHttp\HttpService(); $service->setDefaultAdapter($adapter); $conn = new PAIA(new \VuFind\Date\Converter(), new \Zend\Session\SessionManager()); $conn->setHttpService($service); return $conn; }