ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
CollectorFactory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
23 
33 use Throwable;
35 
42 {
43  use SingletonTrait;
44 
45  protected static array $instances = [];
46 
51  public function __construct(private ProviderFactory $provider_factory)
52  {
53  }
54 
59  public function mainmenu(): MainMenuMainCollector
60  {
61  if (!$this->has(MainMenuMainCollector::class)) {
62  $providers = $this->provider_factory->getMainBarProvider();
63  $information = $this->provider_factory->getMainBarItemInformation();
64 
65  return $this->getWithMultipleArguments(
66  MainMenuMainCollector::class,
67  [
68  $providers,
69  new MainMenuItemFactory(),
70  $information
71  ]
72  );
73  }
74 
75  return $this->get(MainMenuMainCollector::class);
76  }
77 
78  public function metaBar(): MetaBarMainCollector
79  {
80  return $this->getWithArgument(MetaBarMainCollector::class, $this->provider_factory->getMetaBarProvider());
81  }
82  public function footer(): FooterMainCollector
83  {
84  if (!$this->has(FooterMainCollector::class)) {
85  $providers = $this->provider_factory->getFooterProvider();
86  $information = $this->provider_factory->getFooterItemInformation();
87 
88  return $this->getWithMultipleArguments(
89  FooterMainCollector::class,
90  [
91  $providers,
92  $information
93  ]
94  );
95  }
96 
97  return $this->get(FooterMainCollector::class);
98  }
99 
100  public function tool(): MainToolCollector
101  {
102  if (!$this->has(MainToolCollector::class)) {
103  $providers = $this->provider_factory->getToolProvider();
104  $information = $this->provider_factory->getMainBarItemInformation();
105 
106  return $this->getWithMultipleArguments(MainToolCollector::class, [$providers, $information]);
107  }
108 
109  return $this->get(MainToolCollector::class);
110  }
111 
112  public function layout(): MainLayoutCollector
113  {
114  return $this->getWithMultipleArguments(MainLayoutCollector::class, [$this->provider_factory->getModificationProvider()]);
115  }
116 
117  public function notifications(): MainNotificationCollector
118  {
119  return $this->getWithArgument(MainNotificationCollector::class, $this->provider_factory->getNotificationsProvider());
120  }
121 
122  public function toasts(): ToastCollector
123  {
124  return $this->getWithArgument(ToastCollector::class, $this->provider_factory->getToastsProvider());
125  }
126 }
getWithMultipleArguments(string $class_name, array $arguments)
trait SingletonTrait
Class SingletonTrait.
has(string $class_name)
Class MainMenuItemFactory This factory provides you all available types for MainMenu GlobalScreen Ite...
__construct(private ProviderFactory $provider_factory)
CollectorFactory constructor.
PhpIncompatibleReturnTypeInspection
getWithArgument(string $class_name, $argument)