Mmanos\Search\Query::addCallback PHP Method

addCallback() public method

Add a custom callback fn to be called just before the query is executed.
public addCallback ( Closure $callback, array | string $driver = null ) : Query
$callback Closure
$driver array | string
return Query
    public function addCallback($callback, $driver = null)
    {
        if (!empty($driver)) {
            if (is_array($driver)) {
                if (!in_array($this->index->driver, $driver)) {
                    return $this;
                }
            } else {
                if ($driver != $this->index->driver) {
                    return $this;
                }
            }
        }
        $this->callbacks[] = $callback;
        return $this;
    }