|
|
@ -11,4 +11,69 @@ namespace App\Engine; |
|
|
|
*/ |
|
|
|
class CfnppOptions implements IOptions |
|
|
|
{ |
|
|
|
/** |
|
|
|
* Store variables for use in templates. |
|
|
|
* |
|
|
|
* @var array<string,mixed> |
|
|
|
*/ |
|
|
|
protected $variables; |
|
|
|
|
|
|
|
public function __construct() |
|
|
|
{ |
|
|
|
$this->variables = []; |
|
|
|
} |
|
|
|
|
|
|
|
public function setVariables(array $variables): void |
|
|
|
{ |
|
|
|
$this->variables = $variables; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Retrieve all variables. |
|
|
|
* |
|
|
|
* @return array<string,mixed> |
|
|
|
*/ |
|
|
|
public function getVariables(): array |
|
|
|
{ |
|
|
|
return $this->variables; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Retrieve the value of a single variable. |
|
|
|
* |
|
|
|
* @param string $name |
|
|
|
* @throws Exception if variable does not exist |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
public function getVariable(string $name) |
|
|
|
{ |
|
|
|
if (!isset($this->variables[$name])) |
|
|
|
{ |
|
|
|
throw new \Exception('Unset variable: '.$name); |
|
|
|
} |
|
|
|
return $this->variables[$name]; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Set a single variable. |
|
|
|
* |
|
|
|
* @param string $name |
|
|
|
* @param mixed $value |
|
|
|
* @return void |
|
|
|
*/ |
|
|
|
public function setVariable(string $name, $value): void |
|
|
|
{ |
|
|
|
$this->variables[$name] = $value; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Check if a variable exists. |
|
|
|
* |
|
|
|
* @param string $name |
|
|
|
* @return bool |
|
|
|
*/ |
|
|
|
public function hasVariable(string $name): bool |
|
|
|
{ |
|
|
|
return isset($this->variables[$name]); |
|
|
|
} |
|
|
|
} |
|
|
|