/** * Setup user folder */ private function setupUserFolder($session) { $dirName = EIcmsHelper::generateRandomString(8) . '_' . time() . '/'; $dirPath = EIconfig::$coreDirectoryPath . $dirName; mkdir($dirPath, 0755); $session->set('user_folder', $dirName); }
/** * @Route("wp-export-package", name="_wp-export-package") */ public function exportZipPackage(Request $request) { $session = $request->getSession(); $dbName = $session->get('dbName'); $userDir = $session->get('user_folder'); $folderPath = EIconfig::$coreDirectoryPath . $userDir; EIcmsHelper::createMySQLDump($folderPath, $dbName); $zipName = EIcmsHelper::zipFolder($folderPath, "wp_" . EIcmsHelper::generateRandomString(5)); $session->set('zipName', $zipName); $pathToZipFile = $folderPath . $zipName; $response = new BinaryFileResponse($pathToZipFile); $response->headers->set('Content-Type', mime_content_type($pathToZipFile)); $response->headers->set('Content-Length', filesize($pathToZipFile)); $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $zipName); return $response; }