initial
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
class RsvFormDefinition {
|
||||
public $_elements = [];
|
||||
|
||||
public string $_id = "";
|
||||
|
||||
public string $email_key = "";
|
||||
|
||||
/**
|
||||
* @param array<int,mixed> $definition Full definition array including 'elements' and 'email_key'.
|
||||
*/
|
||||
public function __construct(string $id, array $definition) {
|
||||
$this->_elements = [];
|
||||
|
||||
if (array_key_exists('elements', $definition)) {
|
||||
foreach ($definition['elements'] as $element) {
|
||||
array_push($this->_elements, RsvFormElementDefinition::fromArray($element));
|
||||
}
|
||||
}
|
||||
|
||||
$this->_id = $id;
|
||||
$this->email_key = $definition['email_key'] ?? '';
|
||||
}
|
||||
|
||||
public function getId(): string {
|
||||
return $this->_id;
|
||||
}
|
||||
|
||||
public function getEmailKey(): string {
|
||||
return $this->email_key;
|
||||
}
|
||||
|
||||
|
||||
public function hasElements() : bool {
|
||||
return count($this->_elements) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, RsvFormElementDefinition>
|
||||
*/
|
||||
public function getElements() : array {
|
||||
return $this->_elements;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user