public function queryTranslator($type)
    {
        return function ($query) use ($type) {
            if ($this->isAutoQuotingEnabled()) {
                $query = (new IdentifierQuoter($this))->quote($query);
            }

            /** @var \Cake\ORM\Query $query */
            $query = $this->{'_' . $type . 'QueryTranslator'}($query);
            $translators = $this->_expressionTranslators();
            if (!$translators) {
                return $query;
            }

            $query->traverseExpressions(function ($expression) use ($translators, $query) {
                foreach ($translators as $class => $method) {
                    if ($expression instanceof $class) {
                        $this->{$method}($expression, $query);
                    }
                }
            });

            return $query;
        };
    }