FieldParser
Dynamic Syntax parser
class Winter\Storm\Parse\Syntax\FieldParser
Properties
protected
$fields
:
array
= []
Extracted fields from the template The array key should match a unique field name, and the value is another array with values:
- type: the tag name, eg: text
- default: the default tag text
- *: defined parameters
protected
$registeredTags
:
array
= ["text","textarea","richeditor","markdown","fileupload","mediafinder","dropdown","colorpicker","radio","checkbox","checkboxlist","datepicker","balloon-selector","repeater","variable"]
Registered template tags
protected
$tagPrefix
:
string
= ""
A prefix to place before all tag references eg: {namespace:text}{/namespace:text}
protected
$tags
:
array
= []
Complete tag strings for each field. The array key will match the unique field name and the value is the complete tag string, eg: {text}...{/text}
protected
$template
:
string
= ""
Template contents
Methods
public
final
__construct (string $template, array $options = []
)
Constructor.
Property | Type | Description |
---|---|---|
$template | string |
string
Template to parse. |
$options | array |
array
|
public
getDefaultParams (array $fields = null
)
: array
Returns default values for all fields.
Property | Type | Description |
---|---|---|
$fields | array |
array
|
public getFieldParams (string $field) : array
Returns defined parameters for a single field
Property | Type | Description |
---|---|---|
$field | string |
string
|
public getFieldTags (string $field) : array
Returns tag strings for a specific field
Property | Type | Description |
---|---|---|
$field | string |
string
|
public getFields () : array
Returns all field definitions found in the template
public getTags () : array
Returns all tag strings found in the template
public
static
parse (string $template, array $options = []
)
: static
Static helper for new instances of this class.
Property | Type | Description |
---|---|---|
$template | string |
string
|
$options | array |
array
|
protected processOptionsToArray (string $optionsString) : array
Splits an option string to an array.
one|two -> [one, two] one:One|two:Two -> [one => 'One', two => 'Two'] \Path\To\Class::method -> \Path\To\Class::method(): array
Property | Type | Description |
---|---|---|
$optionsString | string |
string
|
protected processParams (string $value, string $tagName) : array
Processes group 2 from the Tag regex and returns an array of captured parameters.
Property | Type | Description |
---|---|---|
$value | string |
string
|
$tagName | string |
string
|
protected processParamsRegex (string $string) : array
Converts parameter string to an array.
In: name="test" comment="This is a test" Out: ['name' => 'test', 'comment' => 'This is a test']
Property | Type | Description |
---|---|---|
$string | string |
string
|
protected processRepeaterTags (string $template) : array
Processes all repeating tags against a template, this will strip any repeaters from the template for further processing.
Property | Type | Description |
---|---|---|
$template | string |
string
|
protected
processTags (string $template, array $usingTags = null
)
: array
Processes all registered tags against a template.
Property | Type | Description |
---|---|---|
$template | string |
string
|
$usingTags | array |
array
|
protected processTagsRegex (string $string, array $tags) : array
Performs a regex looking for a field type (key) and returns an array where:
0 - The full tag definition, eg: {text name="test"}Foobar{/text} 1 - The opening and closing tag name 2 - The tag parameters as a string, eg: name="test"} and; 2 - The default text inside the tag (optional), eg: Foobar
Property | Type | Description |
---|---|---|
$string | string |
string
|
$tags | array |
array
|
protected processTemplate (string $template) : void
Processes repeating tags first, then registered tags and assigns the results to local object properties.
Property | Type | Description |
---|---|---|
$template | string |
string
|