public getOptions ( array $fields = [], boolean $withUnderscore = false ) : array | ||
$fields | array | if empty array all options will be returned, field names can be either with underscored either without, i.e. _percolate, routing |
$withUnderscore | boolean | should option keys contain underscore prefix |
Résultat | array |
public function getOptions(array $fields = [], $withUnderscore = false)
{
if (!empty($fields)) {
$data = [];
foreach ($fields as $field) {
$key = '_' . ltrim($field, '_');
if ($this->hasParam($key) && '' !== (string) $this->getParam($key)) {
$data[$key] = $this->getParam($key);
}
}
} else {
$data = $this->getParams();
}
if (!$withUnderscore) {
foreach ($data as $key => $value) {
$data[ltrim($key, '_')] = $value;
unset($data[$key]);
}
}
return $data;
}
/** * @param \Elastica\AbstractUpdateAction $source * @return array */ protected function _getMetadata(AbstractUpdateAction $action) { $params = array( 'index', 'type', 'id', 'version', 'version_type', 'routing', 'percolate', 'parent', 'ttl', 'timestamp', 'retry_on_conflict', ); $metadata = $action->getOptions($params, true); return $metadata; }