PhpTek\JSONText\ORM\FieldType\JSONText
Synopsis
class JSONText
extends DBString
{
- // constants
- const JSONTEXT_QUERY_OPERATOR = 1;
- const JSONTEXT_QUERY_JSONPATH = 2;
- // members
- private static string $backend = 'postgres';
- private static array $return_types = ;
- protected boolean $nullifyEmpty = false;
- protected string $returnType = 'json';
- protected JsonStore $jsonStore;
- // methods
- public void requireField()
- public HiddenField scaffoldSearchField()
- public HiddenField scaffoldFormField()
- public JSONText setReturnType()
- public JsonStore getJSONStore()
- public array getStoreAsArray()
- public string toJson()
- public array toSSTypes()
- public array toArray()
- public array first()
- public array last()
- public mixed nth()
- public mixed query()
- private array marshallQuery()
- public JSONText setValue()
- private mixed returnAsType()
- protected JSONBackend backendFactory()
- public boolean isValidJson()
- public boolean isValidDBValue()
- public boolean isValidOperator()
- public bool isValidExpression()
- private mixed castToDBField()
Hierarchy
Extends
- SilverStripe\ORM\FieldType\DBString
Tasks
Line | Task |
---|---|
534+ | Deal with true, false and null then! |
Constants
Name | Value |
---|---|
JSONTEXT_QUERY_OPERATOR | 1 |
JSONTEXT_QUERY_JSONPATH | 2 |
Members
private
- $backend
—
string
Which RDBMS backend are we using? The value set here changes the actual operators and operator-routines for the given backend. - $return_types
—
array
Legitimate query return types.
protected
- $jsonStore
—
\Peekmo\JsonPath\JsonStore
A representation of this field's data as a {@link JSONStore} object. - $nullifyEmpty — boolean
- $returnType
—
string
Default query result return type if nothing different is set via setReturnType().
Methods
private
- castToDBField() — Casts a value to a {@link DBField} subclass.
- marshallQuery() — Based on the passed operator or expression, it marshalls the correct backend matcher method into account.
- returnAsType() — Determine the desired userland format to return all query API method results in.
protected
- backendFactory() — Create an instance of {@link JSONBackend} according to the value of JSONText::backend defined in SS config.
public
- first() — Return an array of the JSON key + value represented as first (top-level) JSON node.
- getJSONStore() — Returns the value of this field as an iterable.
- getStoreAsArray() — Returns the JSON value of this field as an array.
- isValidDBValue()
- isValidExpression() — Is the passed JSPONPath expression valid?
- isValidJson() — Utility method to determine whether a value is really valid JSON or not.
- isValidOperator() — Is the passed JSON operator valid?
- last() — Return an array of the JSON key + value represented as last JSON node.
- nth() — Return an array of the JSON key + value represented as the $n'th JSON node.
- query() — Return the key(s) + value(s) represented by $operator extracting relevant result from the source JSON's structure.
- requireField() — Taken from {@link Text}.
- scaffoldFormField()
- scaffoldSearchField()
- setReturnType() — Tell all class methods to return data as JSON , an array or an array of SilverStripe DBField subtypes.
- setValue() — Same as standard setValue() method except we can also accept a JSONPath expression. This expression will conditionally update the parts of the field's source JSON referenced by $expr with $value then re-set the entire JSON string as the field's new value.
- toArray()
- toJson() — Convert an array to JSON via json_encode().
- toSSTypes() — Convert an array's values into an array of SilverStripe DBField subtypes ala: