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