AbstractJsStrings
extends AbstractHelper
in package
AbstractJsStrings helper for passing transformed text to Javascript
Tags
Table of Contents
- $strings : array<string|int, mixed>
- Strings to convey (key = js key, value = value to map)
- $varName : string
- Variable name to store values
- __construct() : mixed
- Constructor
- addStrings() : void
- Add strings to the internal array.
- getJSON() : string
- Generate JSON from the internal strings
- getJSONFromArray() : string
- Generate JSON from an array
- getScript() : string
- Assign JSON to a variable.
- mapValue() : string
- Transform strings before JSON encoding
Properties
$strings
Strings to convey (key = js key, value = value to map)
protected
array<string|int, mixed>
$strings
= []
$varName
Variable name to store values
protected
string
$varName
Methods
__construct()
Constructor
public
__construct([string $varName = 'vufindString' ]) : mixed
Parameters
- $varName : string = 'vufindString'
-
Variable name to store values
Return values
mixed —addStrings()
Add strings to the internal array.
public
addStrings(array<string|int, mixed> $new) : void
Parameters
- $new : array<string|int, mixed>
-
Strings to add
Return values
void —getJSON()
Generate JSON from the internal strings
public
getJSON() : string
Return values
string —getJSONFromArray()
Generate JSON from an array
public
getJSONFromArray(array<string|int, mixed> $strings) : string
Parameters
- $strings : array<string|int, mixed>
-
Strings to convey (key = js key, value = value to map)
Return values
string —getScript()
Assign JSON to a variable.
public
getScript() : string
Return values
string —mapValue()
Transform strings before JSON encoding
protected
abstract mapValue(string|array<string|int, mixed> $str, string $key) : string
Parameters
- $str : string|array<string|int, mixed>
-
String to transform
- $key : string
-
JSON object key