Backup\Controller\IndexController::downloadContentAction PHP Метод

downloadContentAction() публичный Метод

Download files as gzip
public downloadContentAction ( ) : Zend\Stdlib\ResponseInterface
Результат Zend\Stdlib\ResponseInterface
    public function downloadContentAction()
    {
        $what = $this->params()->fromPost('what');
        if (empty($what) or !is_array($what)) {
            return $this->redirect()->toRoute('module/backup');
        }
        $model = new Model\Content($this->getServiceLocator());
        $content = $model->export($what);
        $filename = 'content-backup-' . date('Y-m-d-H-i-s') . '.xml';
        $headers = new Headers();
        $headers->addHeaderLine('Pragma', 'public')->addHeaderLine('Cache-control', 'must-revalidate, post-check=0, pre-check=0')->addHeaderLine('Cache-control', 'private')->addHeaderLine('Expires', -1)->addHeaderLine('Content-Type', 'application/download')->addHeaderLine('Content-Transfer-Encoding', 'binary')->addHeaderLine('Content-Length', strlen($content))->addHeaderLine('Content-Disposition', 'attachment; filename=' . $filename);
        $response = $this->getResponse();
        $response->setHeaders($headers);
        $response->setContent($content);
        return $response;
    }