ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilGSProviderFactory.php
Go to the documentation of this file.
1<?php
2
6
13{
14
18 private $dic;
19
20
24 public function __construct(Container $dic)
25 {
26 $this->dic = $dic;
27
28 parent::__construct(
29 [],
31 );
32 }
33
34
38 public function getMainBarProvider() : array
39 {
40 $providers = [];
41 // Core
42 $this->appendCore($providers, StaticMainMenuProvider::class);
43
44 // Plugins
45 $this->appendPlugins($providers, StaticMainMenuProvider::class);
46
47 $this->registerInternal($providers);
48
49 return $providers;
50 }
51
52
57 private function appendPlugins(array &$array_of_core_providers, string $interface)
58 {
59 // Plugins
60 static $plugin_providers;
61
62 $plugin_providers = $plugin_providers ?? ilPluginAdmin::getAllGlobalScreenProviders();
63
64 foreach ($plugin_providers as $provider) {
65 if (is_a($provider, $interface)) {
66 $array_of_core_providers[] = $provider;
67 }
68 }
69 }
70
71
76 private function appendCore(array &$array_of_providers, string $interface)
77 {
78 static $provider_storages;
79
83 $provider_storages = $provider_storages ?? ilGSProviderStorage::get();
84
85 $interface_map = [
86 StaticMainMenuProvider::class => StaticMainMenuProvider::PURPOSE_MAINBAR,
87 ];
88
89 foreach ($provider_storages as $provider_storage) {
90 if ($provider_storage->getPurpose() === $interface_map[$interface]) {
91 if ($this->isInstanceCreationPossible($provider_storage->getProviderClass())) {
92 $array_of_providers[] = $provider_storage->getInstance();
93 }
94 }
95 }
96 }
97}
An exception for terminatinating execution or to throw for unit testing.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:17
isInstanceCreationPossible(string $class_name)
@inheritDoc
Class ilGSProviderFactory.
appendPlugins(array &$array_of_core_providers, string $interface)
__construct(Container $dic)
@inheritDoc
Class ilMMItemInformation.
static getAllGlobalScreenProviders()