public function getToken($request = null)
    {
        $config = $this->_config;

        if ($request === null) {
            return $this->_token;
        }

        $header = $request->getHeaderLine($config['header']);
        if ($header && stripos($header, $config['prefix']) === 0) {
            return $this->_token = str_ireplace($config['prefix'] . ' ', '', $header);
        }

        if (!empty($this->_config['cookie'])) {
            $token = $request->getCookie($this->_config['cookie']);
            if ($token !== null) {
                $token = (string)$token;
            }

            return $this->_token = $token;
        }

        if (!empty($this->_config['parameter'])) {
            $token = $request->getQuery($this->_config['parameter']);
            if ($token !== null) {
                $token = (string)$token;
            }

            return $this->_token = $token;
        }

        return $this->_token;
    }
public function getToken($request = null)
    {
        $config = $this->_config;

        if ($request === null) {
            return $this->_token;
        }

        $header = $request->getHeaderLine($config['header']);
        if ($header && stripos($header, $config['prefix']) === 0) {
            return $this->_token = str_ireplace($config['prefix'] . ' ', '', $header);
        }

        if (!empty($this->_config['cookie'])) {
            $token = $request->getCookie($this->_config['cookie']);
            if ($token !== null) {
                $token = (string)$token;
            }

            return $this->_token = $token;
        }

        if (!empty($this->_config['parameter'])) {
            $token = $request->getQuery($this->_config['parameter']);
            if ($token !== null) {
                $token = (string)$token;
            }

            return $this->_token = $token;
        }

        return $this->_token;
    }
public function getToken ( $ request = null ) { $ config = $ this -> _config ; if ( $ request === null ) { return $ this -> _token ; } $ header = $ request -> getHeaderLine ( $ config [ 'header' ] ) ; if ( $ header && stripos ( $ header , $ config [ 'prefix' ] ) === 0 ) { return $ this -> _token = str_ireplace ( $ config [ 'prefix' ] . ' ' , '' , $ header ) ; } if ( ! empty ( $ this -> _config [ 'cookie' ] ) ) { $ token = $ request -> getCookie ( $ this -> _config [ 'cookie' ] ) ; if ( $ token !== null ) { $ token = ( string ) $ token ; } return $ this -> _token = $ token ; } if ( ! empty ( $ this -> _config [ 'parameter' ] ) ) { $ token = $ request -> getQuery ( $ this -> _config [ 'parameter' ] ) ; if ( $ token !== null ) { $ token = ( string ) $ token ; } return $ this -> _token = $ token ; } return $ this -> _token ; }
Get token from header or query string.

@param \Cake\Http\ServerRequest|null $request Request object.

@return string|null Token string if found else null.
Get token from header or query string .