Bolt\Storage\Query\QueryParameterParser::multipleKeyAndValueHandler PHP Method

multipleKeyAndValueHandler() public method

This handler processes 'triple pipe' queries as implemented in Bolt It looks for three pipes in the key and value and creates an OR composite expression for example: 'username|||email':'fred|||pete'.
public multipleKeyAndValueHandler ( string $key, string $value, Doctrine\DBAL\Query\Expression\ExpressionBuilder $expr ) : Filter | null
$key string
$value string
$expr Doctrine\DBAL\Query\Expression\ExpressionBuilder
return Filter | null
    public function multipleKeyAndValueHandler($key, $value, $expr)
    {
        if (!strpos($key, '|||')) {
            return null;
        }
        $keys = preg_split('/ *(\\|\\|\\|) */', $key);
        $inputKeys = $keys;
        $values = preg_split('/ *(\\|\\|\\|) */', $value);
        $values = array_pad($values, count($keys), end($values));
        $filterParams = [];
        $parts = [];
        $count = 1;
        while (($key = array_shift($keys)) && ($val = array_shift($values))) {
            $multipleValue = $this->multipleValueHandler($key, $val, $this->expr);
            if ($multipleValue) {
                $filter = $multipleValue->getExpression();
                $filterParams = $filterParams + $multipleValue->getParameters();
            } else {
                $val = $this->parseValue($val);
                $placeholder = $key . '_' . $count;
                $filterParams[$placeholder] = $val['value'];
                $exprMethod = $val['operator'];
                $filter = $this->expr->{$exprMethod}($this->alias . $key, ':' . $placeholder);
            }
            $parts[] = $filter;
            $count++;
        }
        $filter = new Filter();
        $filter->setKey($inputKeys);
        $filter->setExpression(call_user_func_array([$expr, 'orX'], $parts));
        $filter->setParameters($filterParams);
        return $filter;
    }