ILIAS  release_8 Revision v8.23
EmptyDependencyMap.php
Go to the documentation of this file.
1 <?php
2 
20 
23 
30 {
31  protected array $maps = [];
32 
36  public function getDependencyWith(Container $DIC, string $fullyQualifiedDomainName, string $for, callable $map)
37  {
38  $result = $map($DIC, $fullyQualifiedDomainName, $for);
39  if ($result) {
40  return $result;
41  } else {
42  return $this->getDependency($DIC, $fullyQualifiedDomainName, $for);
43  }
44  }
45 
51  public function with(callable $map): DependencyMap
52  {
53  $dependency_map = new static();
54  $dependency_map->maps = array_merge([$map], $this->maps);
55 
56  return $dependency_map;
57  }
58 
62  public function getDependency(Container $DIC, string $fullyQualifiedDomainName, string $for)
63  {
64  foreach ($this->maps as $map) {
65  $result = $map($DIC, $fullyQualifiedDomainName, $for);
66  if ($result) {
67  return $result;
68  }
69  }
70 
71  throw new NoSuchServiceException("The requested service " . $fullyQualifiedDomainName
72  . " could not be resolved.");
73  }
74 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:31
global $DIC
Definition: feed.php:28
getDependencyWith(Container $DIC, string $fullyQualifiedDomainName, string $for, callable $map)
The DIC to take the dependencies from. What domain name is requested? (DIC $DIC, string $fullyQualifi...
with(callable $map)
Returns a new dependency map with the given mapping.
getDependency(Container $DIC, string $fullyQualifiedDomainName, string $for)
The DIC to take the dependencies from. What domain name is requested? What class is the dependency fo...