ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
VocabValueValidator.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 
26 {
27  use DataFetcher;
28  use VocabularyBridge;
29 
30  public function isValid(
31  ElementInterface $element,
32  bool $ignore_marker
33  ): bool {
34  $vocab_values = [];
35  foreach ($this->vocabularies($element, $ignore_marker) as $vocabulary) {
36  $vocab_values = array_merge(
37  $vocab_values,
38  iterator_to_array($vocabulary->values())
39  );
40  }
41  return in_array(
42  $this->normalize($this->dataValue($element, $ignore_marker)),
43  array_map(
44  fn (string $s) => $this->normalize($s),
45  $vocab_values
46  )
47  );
48  }
49 
53  protected function normalize(string $string): string
54  {
55  return str_replace(' ', '', strtolower($string));
56  }
57 }
isValid(ElementInterface $element, bool $ignore_marker)
normalize(string $string)
This is done to ensure backwards compatibility.
vocabularies(ElementInterface $element, bool $ignore_marker)