/** * {@inheritdoc} */ public function excerpt($query, $fields, \record_adapter $record, SearchEngineOptions $options = null) { if (null === $options) { $options = new SearchEngineOptions(); } $ret = []; $this->initialize(); $this->checkSession(); $offset = $record->get_number() + 1; $res = phrasea_fetch_results($this->app['session']->get('phrasea_session_id'), $offset, 1, true, "[[em]]", "[[/em]]"); if (!isset($res['results']) || !is_array($res['results'])) { return []; } $rs = $res['results']; $res = array_shift($rs); if (!isset($res['xml'])) { return []; } $sxe = @simplexml_load_string($res['xml']); foreach ($fields as $name => $field) { $newValues = []; if ($sxe && $sxe->description && $sxe->description->{$name}) { foreach ($sxe->description->{$name} as $value) { $newValues[(string) $value['meta_id']] = (string) $value; } $ret[$name] = $newValues; } } return $ret; }