ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Reader.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 
29 class Reader implements ReaderInterface
30 {
32  protected SetInterface $set;
33 
34  public function __construct(
35  NavigatorFactoryInterface $navigator_factory,
36  SetInterface $set
37  ) {
38  $this->navigator_factory = $navigator_factory;
39  $this->set = $set;
40  }
41 
45  public function allData(PathInterface $path): \Generator
46  {
47  $navigator = $this->navigator_factory->navigator($path, $this->set->getRoot());
48  foreach ($navigator->elementsAtFinalStep() as $element) {
49  yield $element->getData();
50  }
51  }
52 
54  {
55  $navigator = $this->navigator_factory->navigator($path, $this->set->getRoot());
56  if ($first = $navigator->elementsAtFinalStep()->current()) {
57  return $first->getData();
58  }
59  return new NullData();
60  }
61 }
__construct(NavigatorFactoryInterface $navigator_factory, SetInterface $set)
Definition: Reader.php:34
firstData(PathInterface $path)
Get the data of the first of the elements specified by the path.
Definition: Reader.php:53
$path
Definition: ltiservices.php:29
NavigatorFactoryInterface $navigator_factory
Definition: Reader.php:31
allData(PathInterface $path)
Definition: Reader.php:45