Example #1
0
 public function __invoke(Context $context, callable $next)
 {
     if ($this->attributes['nfile.uploadUrl'] === $context->getUri()->getPath()) {
         $this->routeUpload($context);
     } else {
         // initiate repository
         $repository = $this->getRepository($context);
         if (isset($context['timezone'])) {
             $repository->setAttribute('timezone', $context['timezone']);
         }
         if (null !== $context['@renderer']) {
             $context['@renderer']->addTemplatePath(__DIR__ . '/../../templates');
         }
         $context['@norm'] = $this;
         $next($context);
     }
 }
 public function negotiate(Context $context)
 {
     $contentType = $context->getContentType();
     if ($contentType) {
         return $contentType;
     }
     $ext = $context->getUri()->getExtension();
     if ($ext && $this['accepts'][$ext]) {
         return $this['accepts'][$ext];
     }
     $contentType = $context->getRequest()->getContentType();
     if (!$contentType) {
         $accepted = $context->accepts(array_keys($this['accepts']));
         if (isset($accepted)) {
             $contentType = is_string($this['accepts'][$accepted]) ? $this['accepts'][$accepted] : $accepted;
         }
     }
     if ($contentType) {
         return $this->match($contentType);
     }
 }