ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ProviderFactory.php
Go to the documentation of this file.
2 
7 
14 {
15 
19  private $main_bar_providers = [];
27  protected $all_providers;
28 
29 
37  {
38  $this->main_bar_providers = $main_bar_providers;
39  $this->main_menu_item_information = $main_menu_item_information;
40 
41  $this->registerInternal($main_bar_providers);
42  }
43 
44 
48  protected function registerInternal(array $providers)
49  {
50  array_walk(
51  $providers,
52  function (Provider $item) {
53  $this->all_providers[get_class($item)] = $item;
54  }
55  );
56  }
57 
58 
62  public function getMainBarProvider() : array
63  {
65  }
66 
67 
72  {
74  }
75 
76 
80  public function getProviderByClassName(string $class_name) : Provider
81  {
82  if (!$this->isInstanceCreationPossible($class_name) || !$this->isRegistered($class_name)) {
83  throw new \LogicException("the GlobalScreen-Provider $class_name is not available");
84  }
85 
86  return $this->all_providers[$class_name];
87  }
88 
89 
93  public function isInstanceCreationPossible(string $class_name) : bool
94  {
95  return class_exists($class_name);
96  }
97 
98 
102  public function isRegistered(string $class_name) : bool
103  {
104  return isset($this->all_providers[$class_name]);
105  }
106 }
__construct(array $main_bar_providers, ItemInformation $main_menu_item_information)
ProviderFactory constructor.