protected function formatter(ServerRequestInterface $request)
    {
        $accept = $request->getHeaderLine('Accept');
        $priorities = $this->priorities();

        if (!empty($accept)) {
            $preferred = $this->negotiator->getBest($accept, array_keys($priorities));
        }

        if (!empty($preferred)) {
            $formatter = $priorities[$preferred->getValue()];
        } else {
            $formatter = array_shift($priorities);
        }

        return $this->resolve($formatter);
    }
protected function formatter(ServerRequestInterface $request)
    {
        $accept = $request->getHeaderLine('Accept');
        $priorities = $this->priorities();

        if (!empty($accept)) {
            $preferred = $this->negotiator->getBest($accept, array_keys($priorities));
        }

        if (!empty($preferred)) {
            $formatter = $priorities[$preferred->getValue()];
        } else {
            $formatter = array_shift($priorities);
        }

        return $this->resolve($formatter);
    }
protected function formatter ( ServerRequestInterface $ request ) { $ accept = $ request -> getHeaderLine ( 'Accept' ) ; $ priorities = $ this -> priorities ( ) ; if ( ! empty ( $ accept ) ) { $ preferred = $ this -> negotiator -> getBest ( $ accept , array_keys ( $ priorities ) ) ; } if ( ! empty ( $ preferred ) ) { $ formatter = $ priorities [ $ preferred -> getValue ( ) ] ; } else { $ formatter = array_shift ( $ priorities ) ; } return $ this -> resolve ( $ formatter ) ; }
Retrieve the formatter to use for the current request.

Uses content negotiation to find the best available output format for
the requested content type.

@param ServerRequestInterface $request

@return FormatterInterface
Retrieve the formatter to use for the current request .