ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilMailSearchLuceneResultParser.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  public function __construct(protected ilMailSearchResult $result, protected string $xml)
24  {
25  }
26 
27  public function getXml(): string
28  {
29  return $this->xml;
30  }
31 
32  public function getResult(): ilMailSearchResult
33  {
34  return $this->result;
35  }
36 
37  public function parse(): void
38  {
39  if ($this->getXml() === '') {
40  return;
41  }
42 
43  $hits = new SimpleXMLElement($this->getXml());
44  foreach ($hits->children() as $user) {
45  foreach ($user->children() as $item) {
46  $fields = [];
47  foreach ($item->children() as $field) {
48  $name = (string) $field['name'];
49  $content = (string) $field;
50  $fields[] = [
51  $name, $content,
52  ];
53  }
54  $this->getResult()->addItem((int) $item['id'], $fields);
55  }
56  }
57  }
58 }
__construct(protected ilMailSearchResult $result, protected string $xml)