public function matches(Event $event)
    {
        /* @var \Cake\Http\ServerRequest $request */
        $request = $event->getData('request');
        $pass = true;
        if (!empty($this->_config['for'])) {
            $len = strlen('preg:');
            $for = $this->_config['for'];
            $url = $request->getRequestTarget();
            if (substr($for, 0, $len) === 'preg:') {
                $pass = (bool)preg_match(substr($for, $len), $url);
            } else {
                $pass = strpos($url, $for) === 0;
            }
        }
        if ($pass && !empty($this->_config['when'])) {
            $response = $event->getData('response');
            $pass = $this->_config['when']($request, $response);
        }

        return $pass;
    }