ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
Services.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\MetaData\Services;
22 
33 
34 class Services implements ServicesInterface
35 {
37 
40 
41  public function __construct(GlobalContainer $dic)
42  {
43  $this->internal_services = new InternalServices($dic);
44  }
45 
46  public function read(
47  int $obj_id,
48  int $sub_id,
49  string $type,
50  PathInterface $limited_to = null
51  ): ReaderInterface {
52  if ($sub_id === 0) {
53  $sub_id = $obj_id;
54  }
55 
56  $repo = $this->internal_services->repository()->repository();
57  if (isset($limited_to)) {
58  $set = $repo->getMDOnPath($limited_to, $obj_id, $sub_id, $type);
59  } else {
60  $set = $repo->getMD($obj_id, $sub_id, $type);
61  }
62  return new Reader(
63  $this->internal_services->paths()->navigatorFactory(),
64  $set
65  );
66  }
67 
68  public function manipulate(int $obj_id, int $sub_id, string $type): ManipulatorInterface
69  {
70  $repo = $this->internal_services->repository()->repository();
71  $set = $repo->getMD($obj_id, $sub_id, $type);
72  return new Manipulator(
73  $this->internal_services->manipulator()->manipulator(),
74  $set
75  );
76  }
77 
78  public function paths(): PathsInterface
79  {
80  if (isset($this->paths)) {
81  return $this->paths;
82  }
83  return new Paths(
84  $this->internal_services->paths()->pathFactory()
85  );
86  }
87 
88  public function dataHelper(): DataHelperInterface
89  {
90  if (isset($this->data_helper)) {
91  return $this->data_helper;
92  }
93  return new DataHelper(
94  $this->internal_services->dataHelper()->dataHelper(),
95  $this->internal_services->presentation()->data()
96  );
97  }
98 }
dataHelper()
The data carried by many LOM elements is in LOM-specific formats.
Definition: Services.php:88
DataHelperInterface $data_helper
Definition: Services.php:39
manipulate(int $obj_id, int $sub_id, string $type)
Get a manipulator, which can manipulate the LOM of an ILIAS object.
Definition: Services.php:68
$dic
Definition: result.php:32
paths()
Elements in LOM are identified by paths to them from the root.
Definition: Services.php:78
InternalServices $internal_services
Definition: Services.php:36
read(int $obj_id, int $sub_id, string $type, PathInterface $limited_to=null)
Get a reader, which can read out LOM of an ILIAS object.
Definition: Services.php:46
__construct(GlobalContainer $dic)
Definition: Services.php:41