ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ModeFactory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Survey\Mode;
22 
26 
31 {
33  protected ?array $providers = null;
35 
36  public function __construct()
37  {
38  }
39 
40  public function setInternalService(InternalService $service): void
41  {
42  $this->service = $service;
43  }
44  protected function initProviders(): void
45  {
46  if (is_null($this->providers)) {
47  $gui = $this->service->gui();
48  $this->providers = [
49  new Standard\ModeProvider($gui),
50  new Feedback360\ModeProvider($gui),
53  ];
54  }
55  }
56 
57  public function getModeById(int $id): ModeProvider
58  {
59  $this->initProviders();
60  foreach ($this->providers as $provider) {
61  if ($provider->getId() === $id) {
62  $provider->setInternalService($this->service);
63  return $provider;
64  }
65  }
66  throw new ModeException("Unknown mode: " . $id);
67  }
68 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$provider
Definition: ltitoken.php:80
setInternalService(InternalService $service)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23