コード例 #1
0
ファイル: JsonView.php プロジェクト: BergischMedia/vidi
 /**
  * @return string
  */
 public function render()
 {
     # As of this writing, Json header is not automatically sent in the BE... even with json=format.
     $this->response->setHeader('Content-Type', 'application/json');
     $this->response->sendHeaders();
     return json_encode($this->result->toArray());
 }
コード例 #2
0
 /**
  * Redirects the web request to another uri.
  *
  * NOTE: This method only supports web requests and will thrown an exception if used with other request types.
  *
  * @param string $uri A string representation of a URI
  * @param int $delay (optional) The delay in seconds. Default is no delay.
  * @param int $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other
  * @throws UnsupportedRequestTypeException If the request is not a web request
  * @throws StopActionException
  */
 protected function redirectToUri(string $uri, int $delay = 0, int $statusCode = 303)
 {
     if (!$this->request instanceof Request) {
         throw new UnsupportedRequestTypeException('redirect() only supports web requests.', 1471776458);
     }
     $uri = $this->addBaseUriIfNecessary($uri);
     $escapedUri = htmlentities($uri, ENT_QUOTES, 'utf-8');
     $this->response->setContent('<html><head><meta http-equiv="refresh" content="' . (int) $delay . ';url=' . $escapedUri . '"/></head></html>');
     if ($this->response instanceof \TYPO3\CMS\Extbase\Mvc\Web\Response) {
         $this->response->setStatus($statusCode);
         $this->response->setHeader('Location', (string) $uri);
     }
     echo $this->response->shutdown();
     throw new StopActionException('redirectToUri', 1477070964);
 }
コード例 #3
0
 /**
  * @param \I4W\Fileshare\Domain\Model\Share $share
  * @throws \RuntimeException
  * @throws \TYPO3\CMS\Core\Error\Http\PageNotFoundException
  * @return string
  * @dontvalidate
  */
 public function downloadAllAction(\I4W\Fileshare\Domain\Model\Share $share = null)
 {
     if (false === $share instanceof Share) {
         throw new PageNotFoundException('Could not find  share', 1435910678);
     }
     $zip = new \ZipArchive();
     $res = $zip->open($share->getToken() . '.zip', \ZipArchive::CREATE);
     if (!$res) {
         throw new \RuntimeException('Could not create ZIP archive', 1435909664);
     }
     foreach ($this->getFilesFromShare($share) as $file) {
         /** @var File $file */
         $zip->addFromString($file->getName(), $file->getContents());
     }
     $zip->close();
     $this->response->setHeader('Cache-control', 'public', true);
     $this->response->setHeader('Content-Description', 'File transfer', true);
     $this->response->setHeader('Content-Disposition', 'attachment; filename=' . $share->getToken() . '.zip', true);
     $this->response->setHeader('Content-Type', 'application/zip', true);
     $this->response->sendHeaders();
     readfile($share->getToken() . '.zip');
     exit;
 }