/** * Set raw data to initialize the object. * * @param mixed $data Raw data representing the record; Record Model * objects are normally constructed by Record Driver objects using data * passed in from a Search Results object. In this case, $data is a Solr record * array containing MARC data in the 'fullrecord' field. * * @return void */ public function setRawData($data) { // Call the parent's set method... parent::setRawData($data); // Also process the MARC record: $marc = trim($data['fullrecord']); // check if we are dealing with MARCXML $xmlHead = '<?xml version'; if (strcasecmp(substr($marc, 0, strlen($xmlHead)), $xmlHead) === 0) { $marc = new \File_MARCXML($marc, \File_MARCXML::SOURCE_STRING); } else { $marc = preg_replace('/#31;/', "", $marc); $marc = preg_replace('/#30;/', "", $marc); $marc = new \File_MARC($marc, \File_MARC::SOURCE_STRING); } $this->marcRecord = $marc->next(); if (!$this->marcRecord) { throw new \File_MARC_Exception('Cannot Process MARC Record'); } }
/** * Set raw data to initialize the object. * * @param mixed $data Raw data representing the record; Record Model * objects are normally constructed by Record Driver objects using data * passed in from a Search Results object. In this case, $data is a Solr record * array containing MARC data in the 'fullrecord' field. * * @return void */ public function setRawData($data) { // Call the parent's set method... parent::setRawData($data); // Also process the MARC record: $marc = trim($data['fullrecord']); // check if we are dealing with MARCXML if (substr($marc, 0, 1) == '<') { $marc = new \File_MARCXML($marc, \File_MARCXML::SOURCE_STRING); } else { // When indexing over HTTP, SolrMarc may use entities instead of certain // control characters; we should normalize these: $marc = str_replace(['#29;', '#30;', '#31;'], ["", "", ""], $marc); $marc = new \File_MARC($marc, \File_MARC::SOURCE_STRING); } $this->marcRecord = $marc->next(); if (!$this->marcRecord) { throw new \File_MARC_Exception('Cannot Process MARC Record'); } }
/** * Set raw data to initialize the object. * * @param mixed $data Raw data representing the record; Record Model * objects are normally constructed by Record Driver objects using data * passed in from a Search Results object. The exact nature of the data may * vary depending on the data source -- the important thing is that the * Record Driver + Search Results objects work together correctly. * * @return void */ public function setRawData($data) { parent::setRawData($data); $this->simpleXML = null; }
/** * Get a record driver with fake data. * * @param array $overrides Fixture fields to override. * * @return SolrDefault */ protected function getDriver($overrides = []) { $fixture = json_decode(file_get_contents(realpath(VUFIND_PHPUNIT_MODULE_PATH . '/fixtures/misc/testbug2.json')), true); $record = new SolrDefault(); $record->setRawData($overrides + $fixture['response']['docs'][0]); return $record; }
/** * Set raw data to initialize the object. * * @param mixed $data Raw data representing the record; Record Model * objects are normally constructed by Record Driver objects using data * passed in from a Search Results object. The exact nature of the data may * vary depending on the data source -- the important thing is that the * Record Driver + Search Results objects work together correctly. * * @return void */ public function setRawData($data) { parent::setRawData($data); $this->lazyRecordXML = null; }