public function injectSearch(Event $event)
    {
        if (!in_array($event->getName(), $this->getConfig('enabled'))) {
            return;
        }

        $repository = $this->_table();
        if ($repository instanceof Table && !$repository->behaviors()->has('Search')) {
            throw new RuntimeException(sprintf(
                'Missing Search.Search behavior on %s',
                get_class($repository)
            ));
        }

        if ($repository instanceof Table && $repository->behaviors()->hasMethod('filterParams')) {
            $filterParams = $repository->filterParams($this->_request()->getQuery());
        } else {
            $filterParams = ['search' => $this->_request()->getQuery()];
        }

        $filterParams['collection'] = $this->getConfig('collection');
        $event->getSubject()->query->find('search', $filterParams);
    }