Example #1
0
 public function indexAction()
 {
     $response = $this->getResponse();
     $resourcePath = $this->params()->fromRoute('resourcePath');
     $asset = $this->findAsset($resourcePath);
     if (!$asset) {
         $response->setStatusCode(404);
         return;
     }
     $response->setContent($asset->dump());
     $headers = $response->getHeaders();
     if (null !== $asset->getLastModified()) {
         $headers->addHeaderLine('Last-Modified', '@' . $asset->getLastModified());
     }
     $extension = pathinfo($resourcePath, PATHINFO_EXTENSION);
     if ($extension && $this->contentTypeResolver->hasMapping($extension)) {
         $headers->addHeaderLine('Content-Type', $this->contentTypeResolver->resolve($extension));
     }
     return $response;
 }