/** * Create service * * @param ServiceLocatorInterface $serviceLocator * @return mixed */ public function createService(ServiceLocatorInterface $serviceLocator) { $options = $serviceLocator->get('Config'); $options = $options['bedrest']; $negotiator = new Negotiator(); $negotiator->setSupportedMediaTypes($options['supported_content_types']); return $negotiator; }
public function testDecodeWithInvalidContentTypeThrowsException() { $this->setExpectedException('\\BedRest\\Content\\Negotiation\\Exception'); $this->negotiator->decode('raw_data', 'application/json'); }
/** * @param string|ModelInterface $nameOrModel The script/resource process, or a view model * @param null|array|\ArrayAccess $values Values to use during rendering * @return string The script output. */ public function render($nameOrModel, $values = null) { $result = $this->negotiator->negotiate($nameOrModel->getVariables(), $nameOrModel->getAccept()); return $result; }