ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Factory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 
28 class Factory
29 {
30  private array $engines_strings = [];
31  private array $engines = [];
32 
33  public function __construct(array $additional_engines = [])
34  {
35  $this->engines_strings = array_merge($additional_engines, [
36  ImagickEngine::class,
37  GDEngine::class,
38  FFMpegEngine::class,
39  ImagickEngineWithOptionalFFMpeg::class,
40  NoEngine::class
41  ]);
42  }
43 
44  public function get(FlavourMachine $machine): ?Engine
45  {
46  $depends_on = $machine->dependsOnEngine();
47  if (!in_array($depends_on, $this->engines_strings, true)) {
48  return null;
49  }
50  if (isset($this->engines[$depends_on])) {
51  return $this->engines[$depends_on];
52  }
53 
54  try {
55  $engine = $this->engines[$depends_on] = new $depends_on();
56  } catch (\Throwable) {
57  return null;
58  }
59  return $engine;
60  }
61 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(array $additional_engines=[])
Definition: Factory.php:33