ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Factory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\MetaData\Elements;
22 
29 
30 class Factory
31 {
33 
34  public function __construct(
35  DataFactoryInterface $data_factory
36  ) {
37  $this->data_factory = $data_factory;
38  }
39 
40  public function element(
41  int $md_id,
42  DefinitionInterface $definition,
43  string $data_value,
44  SlotIdentifier $vocab_slot = SlotIdentifier::NULL,
45  Element ...$sub_elements
46  ): Element {
47  return new Element(
48  $md_id,
49  $definition,
50  $this->data_factory->data($definition->dataType(), $data_value, $vocab_slot),
51  ...$sub_elements
52  );
53  }
54 
55  public function root(
56  DefinitionInterface $definition,
57  Element ...$sub_elements
58  ): ElementInterface {
59  return new Element(
60  NoID::ROOT,
61  $definition,
62  $this->data_factory->null(),
63  ...$sub_elements
64  );
65  }
66 
67  public function set(
68  RessourceIDInterface $ressource_id,
69  ElementInterface $root
70  ): SetInterface {
71  return new Set(
72  $ressource_id,
73  $root
74  );
75  }
76 }
root(DefinitionInterface $definition, Element ... $sub_elements)
Definition: Factory.php:55
element(int $md_id, DefinitionInterface $definition, string $data_value, SlotIdentifier $vocab_slot=SlotIdentifier::NULL, Element ... $sub_elements)
Definition: Factory.php:40
DataFactoryInterface $data_factory
Definition: Factory.php:32
dataType()
Type of data this element can carry.
__construct(DataFactoryInterface $data_factory)
Definition: Factory.php:34