You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.2 KiB
64 lines
1.2 KiB
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App;
|
|
|
|
/**
|
|
* Main logic for actually doing things with the passed in config
|
|
*
|
|
* @author Adam Pippin <hello@adampippin.ca>
|
|
*/
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|