enable()
+ +enable(): void+
Enables Cakephp 3.x compatibility by aliasing some classes that have been renamed in CakePHP 4.x
It must be called at bootstrap step
+
Used when a behavior cannot be found.
+Used when a behavior cannot be found.
++ +
isDatField(mixed $datfield): integer
+ Utility function to check if a field is datfield in driver +It must detect unstranslated and already translated datfield as well
mixed | +$datfield | +Field name |
+
0 if not a datfield, 1 for v1 notation, 2 for v2 notation, 3 for DatfieldExpression
translateExpression(string|array|\Cake\Database\ExpressionInterface $expression,\Cake\Database\Query $query,\Lqdt\OrmJson\Database\JsonTypeMap $jsonTypes): string|array|\Cake\Database\ExpressionInterface+
Applies datfield translation to any expression or SQL snippets
string|array|\Cake\Database\ExpressionInterface | +$expression | +Literal or object expression |
+
\Cake\Database\Query | +$query | +Query |
+
\Lqdt\OrmJson\Database\JsonTypeMap | +$jsonTypes | +JSON types definition |
+
Updated expression
translateDatField(array|string|\Cake\Database\ExpressionInterface $datfield,boolean $unquote = false,string|null|false $repository = null): array|string|\Cake\Database\ExpressionInterface+
Translates a datfield notation into a valid driver dependent SQL FunctionExpression that allows +to identify and target data into a JSON field.
If a repository is prepended to datfield, il will be kept as is unless passing false as last argument
array|string|\Cake\Database\ExpressionInterface | +$datfield | +Datfield |
+
boolean | +$unquote | +If |
+
string|null|false | +$repository | +Repository alias |
+
translateSetDatField(\Cake\Database\Expression\ComparisonExpression $expr,\Cake\Database\Query $query,\Lqdt\OrmJson\Database\JsonTypeMap $map): \Cake\Database\Expression\ComparisonExpression+
Translates a SET comparison expression to directly update JSON data based on datfield
It is used for UPDATE statements
\Cake\Database\Expression\ComparisonExpression | +$expr | +Expression |
+
\Cake\Database\Query | +$query | +Query |
+
\Lqdt\OrmJson\Database\JsonTypeMap | +$map | +JSON type map |
+
Updated expression
+ + + +
+ + + +
_registerDatFieldForSorting(\Lqdt\OrmJson\Database\Dialect\string $datfield, \Lqdt\OrmJson\Database\Dialect\string $model, array $aliases, \Cake\Database\Query $query)+
+ + +
\Lqdt\OrmJson\Database\Dialect\string | +$datfield | ++ |
\Lqdt\OrmJson\Database\Dialect\string | +$model | ++ |
array | +$aliases | ++ |
\Cake\Database\Query | +$query | ++ |
+ + + +
_decorateExtractedDatFields( $row, \Lqdt\OrmJson\Database\Dialect\string $separator, \Lqdt\OrmJson\Database\Dialect\bool $keepNestedOnExtract)+
+ + +
+ | $row | ++ |
\Lqdt\OrmJson\Database\Dialect\string | +$separator | ++ |
\Lqdt\OrmJson\Database\Dialect\bool | +$keepNestedOnExtract | ++ |
_selectRegularField(\Lqdt\OrmJson\Database\Dialect\string $field, \Lqdt\OrmJson\Database\Dialect\string $alias, array $fields)+
+ + +
\Lqdt\OrmJson\Database\Dialect\string | +$field | ++ |
\Lqdt\OrmJson\Database\Dialect\string | +$alias | ++ |
array | +$fields | ++ |
_selectDatField(\Lqdt\OrmJson\Database\Dialect\string $datfield, array $fields, array $filteredFields, \Cake\Database\Query $query)+
+ + +
\Lqdt\OrmJson\Database\Dialect\string | +$datfield | ++ |
array | +$fields | ++ |
array | +$filteredFields | ++ |
\Cake\Database\Query | +$query | ++ |
_extractDatField(\Lqdt\OrmJson\Database\Dialect\string $datfield, \Lqdt\OrmJson\Database\Dialect\string $alias, array $fields, \Cake\Database\Query $query)+
+ + +
\Lqdt\OrmJson\Database\Dialect\string | +$datfield | ++ |
\Lqdt\OrmJson\Database\Dialect\string | +$alias | ++ |
array | +$fields | ++ |
\Cake\Database\Query | +$query | ++ |
+ + + +
_filtersConverter(string|\Cake\Database\ExpressionInterface $expression, \Cake\Database\Query $query)+
Returns the appropriate ExpressionInterface regarding the incoming one
+ + +string|\Cake\Database\ExpressionInterface | +$expression | +Incoming expression |
+
\Cake\Database\Query | +$query | ++ |
_rawSqlConverter(string $expression, \Cake\Database\Query $query) : \Cake\Database\Expression\QueryExpression+
Returns a new QueryExpression built upon the parsing of the expression to +update datfield names
+ + +string | +$expression | +Raw expression to transform |
+
\Cake\Database\Query | +$query | ++ |
QueryExpression
+ +_comparisonConverter(\Cake\Database\Expression\Comparison $expression, \Cake\Database\Query $query) : \Cake\Database\Expression\Comparison|\Cake\Database\Expression\QueryExpression+
Update or replace the Comparison expression to perform comparisons on +datFields. In some cases, PDO limitations implies to replace the +expression with a raw SQL fragment. It can be a bit dangerous when +using raw user input to perform global matching in `array` mode.
+Regular fields expressions are left as is.
+ +\Cake\Database\Expression\Comparison | +$expression | +Comparison expression |
+
\Cake\Database\Query | +$query | ++ |
Updated expression
+ +_unaryExpressionConverter(\Cake\Database\Expression\UnaryExpression $expression, \Cake\Database\Query $query) : \Cake\Database\Expression\UnaryExpression+
Parses the unary expression to apply conversions on childrens and returns +an updated UnaryExpression
+Note : This a VERY hacky way because the UnaryExpression class doesn't expose
+getter/setter for protected _value
property.
In this implementation, it causes an infinite loop when used directly with a SQL fragment :
+['NOT' => 'sub.prop@datfield like "%buggy%"]
That's why, an exception is thrown as soon as $value is extracted
+ +\Cake\Database\Expression\UnaryExpression | +$expression | +Expression |
+
\Cake\Database\Query | +$query | ++ |
New expression
+ +_queryExpressionConverter(\Cake\Database\Expression\QueryExpression $expression, \Cake\Database\Query $query) : \Cake\Database\Expression\QueryExpression+
Iterates over a QueryExpression and replace Comparison expressions +to handle JSON comparison in datfields.
+ + +\Cake\Database\Expression\QueryExpression | +$expression | +QueryExpression |
+
\Cake\Database\Query | +$query | ++ |
Updated QueryExpression
+ ++ + + +
_registerDatFieldForSorting(\Lqdt\OrmJson\Database\Dialect\string $datfield, \Lqdt\OrmJson\Database\Dialect\string $model, array $aliases, \Cake\Database\Query $query)+
+ + +
\Lqdt\OrmJson\Database\Dialect\string | +$datfield | ++ |
\Lqdt\OrmJson\Database\Dialect\string | +$model | ++ |
array | +$aliases | ++ |
\Cake\Database\Query | +$query | ++ |
_decorateExtractedDatFields( $row, \Lqdt\OrmJson\Database\Dialect\string $separator, \Lqdt\OrmJson\Database\Dialect\bool $keepNestedOnExtract)+
+ + +
+ | $row | ++ |
\Lqdt\OrmJson\Database\Dialect\string | +$separator | ++ |
\Lqdt\OrmJson\Database\Dialect\bool | +$keepNestedOnExtract | ++ |
_selectRegularField(\Lqdt\OrmJson\Database\Dialect\string $field, \Lqdt\OrmJson\Database\Dialect\string $alias, array $fields)+
+ + +
\Lqdt\OrmJson\Database\Dialect\string | +$field | ++ |
\Lqdt\OrmJson\Database\Dialect\string | +$alias | ++ |
array | +$fields | ++ |
_selectDatField(\Lqdt\OrmJson\Database\Dialect\string $datfield, array $fields, array $filteredFields, \Cake\Database\Query $query)+
+ + +
\Lqdt\OrmJson\Database\Dialect\string | +$datfield | ++ |
array | +$fields | ++ |
array | +$filteredFields | ++ |
\Cake\Database\Query | +$query | ++ |
_extractDatField(\Lqdt\OrmJson\Database\Dialect\string $datfield, \Lqdt\OrmJson\Database\Dialect\string $alias, array $fields, \Cake\Database\Query $query)+
+ + +
\Lqdt\OrmJson\Database\Dialect\string | +$datfield | ++ |
\Lqdt\OrmJson\Database\Dialect\string | +$alias | ++ |
array | +$fields | ++ |
\Cake\Database\Query | +$query | ++ |
_filtersConverter(string|\Cake\Database\ExpressionInterface $expression, \Cake\Database\Query $query)+
Returns the appropriate ExpressionInterface regarding the incoming one
+ + +string|\Cake\Database\ExpressionInterface | +$expression | +Incoming expression |
+
\Cake\Database\Query | +$query | ++ |
_rawSqlConverter(string $expression, \Cake\Database\Query $query) : \Cake\Database\Expression\QueryExpression+
Returns a new QueryExpression built upon the parsing of the expression to +update datfield names
+ + +string | +$expression | +Raw expression to transform |
+
\Cake\Database\Query | +$query | ++ |
QueryExpression
+ +_comparisonConverter(\Cake\Database\Expression\Comparison $expression, \Cake\Database\Query $query) : \Cake\Database\Expression\Comparison|\Cake\Database\Expression\QueryExpression+
Update or replace the Comparison expression to perform comparisons on +datFields. In some cases, PDO limitations implies to replace the +expression with a raw SQL fragment. It can be a bit dangerous when +using raw user input to perform global matching in `array` mode.
+Regular fields expressions are left as is.
+ +\Cake\Database\Expression\Comparison | +$expression | +Comparison expression |
+
\Cake\Database\Query | +$query | ++ |
Updated expression
+ +_unaryExpressionConverter(\Cake\Database\Expression\UnaryExpression $expression, \Cake\Database\Query $query) : \Cake\Database\Expression\UnaryExpression+
Parses the unary expression to apply conversions on childrens and returns +an updated UnaryExpression
+Note : This a VERY hacky way because the UnaryExpression class doesn't expose
+getter/setter for protected _value
property.
In this implementation, it causes an infinite loop when used directly with a SQL fragment :
+['NOT' => 'sub.prop@datfield like "%buggy%"]
That's why, an exception is thrown as soon as $value is extracted
+ +\Cake\Database\Expression\UnaryExpression | +$expression | +Expression |
+
\Cake\Database\Query | +$query | ++ |
New expression
+ +_queryExpressionConverter(\Cake\Database\Expression\QueryExpression $expression, \Cake\Database\Query $query) : \Cake\Database\Expression\QueryExpression+
Iterates over a QueryExpression and replace Comparison expressions +to handle JSON comparison in datfields.
+ + +\Cake\Database\Expression\QueryExpression | +$expression | +QueryExpression |
+
\Cake\Database\Query | +$query | ++ |
Updated QueryExpression
+ +These upgraded schema provides convenience to handle data types into JSON data
+addJsonTypes(array|string $types,array|null $type = null): void+
Permanently register a JSON type(s) in schema. provided type(s) will be added to current styles +In case of target conflict
array|string | +$types | +Datfield to type or array of [ |
+
array|null | +$type | +Type definition |
+
addTransientJsonTypes(array|string $types,array|null $type = null): void+
Register transient JSON type(s) in schema
These types will be removed after next call to DatFieldTableSchema::typeMap()
array|string | +$types | +Datfield to type or array of [ |
+
array|null | +$type | +Type definition |
+
setJsonTypes(array|string $types,array|null $type = null): void+
Permanently register a JSON type(s) in schema. provided type(s) will replace currently stored +JSON types
array|string | +$types | +Datfield to type or array of [ |
+
array|null | +$type | +Type definition |
+
setTransientJsonTypes(array|string $types,array|null $type = null): void+
Register transient JSON type(s) in schema
These types will be removed after next call to DatFieldTableSchema::typeMap()
array|string | +$types | +Datfield to type or array of [ |
+
array|null | +$type | +Type definition |
+
_parseJsonTypes(array|string $types,array|null $type = null): array+
Process a single or a set of json types and returns it as a suitable array to be stored as json types
array|string | +$types | +Datfield to type or array of [ |
+
array|null | +$type | +Type definition |
+
Processed JSON types
When a table schema implements this interface, its `typeMap` method should return +an array containing regular field type and datfield type definition as well.
Datfield type definition can be either a regular CakePHP data type string string or an array which provides one or more of the following keys :
+type => <string>
: regular CakePHP registered data typemarshal => <callable>
toPHP => <callable>
: Callback to apply on toPHP operations, overrides data type toPHP if one is definedtoDatabase => <callable>
: Callback to apply on toDatabase operations, overrides data type toDatabase if one is definedThe callable callback will be provided with following arguments :
+Returned value will be used to replace value at datfield path
+ +setTransientJsonTypes(array|string $types,array|null $type = null): void+
Register transient JSON type(s) in schema
These types will be removed after next call to DatFieldTableSchema::typeMap()
array|string | +$types | +Datfield to type or array of [ |
+
array|null | +$type | +Type definition |
+
These upgraded schema is needed to handle applying data type into JSON data
+addJsonTypes(array|string $types,array|null $type = null): void+
Permanently register a JSON type(s) in schema. provided type(s) will be added to current styles +In case of target conflict
array|string | +$types | +Datfield to type or array of [ |
+
array|null | +$type | +Type definition |
+
addTransientJsonTypes(array|string $types,array|null $type = null): void+
Register transient JSON type(s) in schema
These types will be removed after next call to DatFieldTableSchema::typeMap()
array|string | +$types | +Datfield to type or array of [ |
+
array|null | +$type | +Type definition |
+
setJsonTypes(array|string $types,array|null $type = null): void+
Permanently register a JSON type(s) in schema. provided type(s) will replace currently stored +JSON types
array|string | +$types | +Datfield to type or array of [ |
+
array|null | +$type | +Type definition |
+
setTransientJsonTypes(array|string $types,array|null $type = null): void+
Register transient JSON type(s) in schema
These types will be removed after next call to DatFieldTableSchema::typeMap()
array|string | +$types | +Datfield to type or array of [ |
+
array|null | +$type | +Type definition |
+
_parseJsonTypes(array|string $types,array|null $type = null): array+
Process a single or a set of json types and returns it as a suitable array to be stored as json types
array|string | +$types | +Datfield to type or array of [ |
+
array|null | +$type | +Type definition |
+
Processed JSON types
This trait adds useful methods to get and set values in JSON fields
+All methods can safely be called on regular fields
+ + +$_hidden :+
+ + +
+
+
+
+
+
+
+
hasProperty(\PHPStan\Reflection\ClassReflection $classReflection,string $propertyName): boolean+
Check that json field owning datfield exists in class
\PHPStan\Reflection\ClassReflection | +$classReflection | +Class reflection |
+
string | +$propertyName | +Datfield |
+
getProperty(\PHPStan\Reflection\ClassReflection $classReflection,string $propertyName): \PHPStan\Reflection\PropertyReflection+
Returns property reflection for datfield
\PHPStan\Reflection\ClassReflection | +$classReflection | +Class reflection |
+
string | +$propertyName | +Property name |
+