CirrusSearch
Elasticsearch-powered search for MediaWiki
|
Transforms arrays based on replacement variable using a syntax to lookup the entry to modify. More...
Public Member Functions | |
__construct (array $replacements) | |
transform (?array $profile=null) | |
Transform the profile. | |
Transforms arrays based on replacement variable using a syntax to lookup the entry to modify.
Examples: [ 'elem1.elem2' => 'value' ] will replace the following profile [ 'elem1' => [ 'elem2' => 'placeholder' ] ] with : [ 'elem1' => [ 'elem2' => 'value' ] ]
The syntax supports lookaheads on next array value: [ 'elem1.*[type=bar].element' => [ 'custom' => 'data' ] ] will replace the following profile [ 'elem1' => [ [ 'type' => 'foo' 'element' => [] ], [ 'type' => 'bar' 'element' => [] ], ] ] with : [ 'elem1' => [ [ 'type' => 'foo' 'element' => [] ], [ 'type' => 'bar' 'element' => [ 'custom' => 'data' ] ], ] ]
A single substition can occur, the first match wins. The full path must always be matched.
CirrusSearch\Profile\ArrayPathSetter::__construct | ( | array | $replacements | ) |
mixed[] | $replacements | array of replacements indexed with a string in the syntax supported by this class |
CirrusSearch\Profile\ArrayPathSetter::transform | ( | ?array | $profile = null | ) |
Transform the profile.
array | null | $profile |