*/ class Engine { /** * The configuration laying out the screens and layouts we're trying to implement * @var Configuration */ protected $_config; /** * The driver to allow us to manipulate display offsets/dimensions/etc * @var ILayoutDriver */ protected $_driver; /** * Set up the engine * @param Configuration $config * @param ILayoutDriver $driver */ public function __construct(\App\Configuration $config, \App\ILayoutDriver $driver) { $this->_config = $config; $this->_driver = $driver; } /** * Perform a layout * * @return void */ public function layout(): void { foreach ($this->_config->getLayouts() as $layout_name => $layout) { $screens = $layout->getScreenNames(); $all_screens = true; foreach ($screens as $screen_name) { if (!$this->_config->getScreen($screen_name)->isConnected()) { $all_screens = false; break; } } if (!$all_screens) { continue; } $layout->execute($this->_config, $this->_driver); break; } } }