More work on Edit Frame

This commit is contained in:
Deon George
2019-10-02 15:47:56 +10:00
parent bb031b1b82
commit d43d5b71fd
5 changed files with 110 additions and 14 deletions

View File

@@ -8,15 +8,14 @@ use App\Classes\Control\Telnet;
abstract class Control
{
const prefix = 'App\Classes\Control\';
// Has this control class finished with input
protected $complete = FALSE;
// The server object that is running this control class
protected $so = NULL;
// The frame applicable for this control (not the current rendered frame, thats in $so)
protected $fo = NULL;
/**
* What is the state of the server outside of this control.
* Should only contain
@@ -27,9 +26,8 @@ abstract class Control
*/
public $state = [];
public function __construct(Server $so,Frame $fo=NULL) {
public function __construct(Server $so,array $args=[]) {
$this->so = $so;
$this->fo = $fo;
// Boot control, preparing anything before keyboard entry
$this->boot();
@@ -48,11 +46,10 @@ abstract class Control
return $this->complete;
}
// @todo Change to Dynamic Calls by the existence of files in App\Classes\Control
public static function factory(string $name,Server $so,Frame $fo=NULL) {
public static function factory(string $name,Server $so,array $args=[]) {
switch ($name) {
case 'editframe':
return new EditFrame($so,$fo);
return new EditFrame($so,$args);
case 'register':
return new Register($so);
@@ -61,7 +58,12 @@ abstract class Control
return new Telnet($so);
default:
throw new \Exception('Unknown control method: '.$name);
$c = self::prefix.$name;
$o = class_exists($c) ? new $c($so,$args) : FALSE;
$so->log('debug',sprintf(($o ? 'Executing: %s' : 'Class doesnt exist: %s'),$c));
return $o;
}
}