Пример #1
0
 /**
  * Get the media type for the request
  *
  * @param ActionInterface $action
  * @return \Aura\Accept\Media\MediaValue|false
  * @throws Exception
  */
 protected function getMedia(ActionInterface $action)
 {
     $available = array_intersect($action->getAllowedFormats(), $this->presenter->getAvailableFormats());
     //@todo don't mix Di and randomly calling factories
     $accept_factory = new AcceptFactory($_SERVER);
     $accept = $accept_factory->newInstance();
     $media = $accept->negotiateMedia($available);
     if (empty($media)) {
         throw new Exception('Could not find a compatible content type for response');
     }
     return $media;
 }
Пример #2
0
 public function __construct()
 {
     $acceptFactory = new AcceptFactory($_SERVER);
     $this->accept = $acceptFactory->newInstance();
 }