/** * Create tests * * @return array */ private function createTests() { $this->fileCreator->createDirectory($this->configSettings['pathTo']['tests'] . 'controller'); $fileName = $this->configSettings['pathTo']['tests'] . "controller/" . $this->nameOf("test") . ".php"; $this->makeFileFromTemplate($fileName, $this->templatePathWithControllerType . "test.txt"); }
private function downloadCSSFramework() { if ($this->configSettings['downloads']['bootstrap']) { $ch = curl_init("https://github.com/twbs/bootstrap/releases/download/v3.1.1/bootstrap-3.1.1-dist.zip"); $fp = fopen("public/bootstrap.zip", "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_exec($ch); curl_close($ch); fclose($fp); $zip = zip_open("public/bootstrap.zip"); if ($zip) { while ($zip_entry = zip_read($zip)) { $foundationFile = "public/" . zip_entry_name($zip_entry); $foundationDir = dirname($foundationFile); $this->fileCreator->createDirectory($foundationDir); if ($foundationFile[strlen($foundationFile) - 1] == "/") { if (!is_dir($foundationDir)) { \File::makeDirectory($foundationDir); } } else { $fp = fopen($foundationFile, "w"); if (zip_entry_open($zip, $zip_entry, "r")) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); fwrite($fp, "{$buf}"); zip_entry_close($zip_entry); fclose($fp); } } } zip_close($zip); \File::delete('public/bootstrap.zip'); $dirPath = 'public/bootstrap-3.1.1-dist'; $this->fileCreator->copyDirectory($dirPath, 'public/bootstrap'); foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dirPath, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $path) { $path->isFile() ? unlink($path->getPathname()) : rmdir($path->getPathname()); } rmdir($dirPath); } $fileReplace = " <link href=\"{{ url('bootstrap/css/bootstrap.min.css') }}\" rel=\"stylesheet\">\n"; $fileReplace .= " <style>\n"; $fileReplace .= " body {\n"; $fileReplace .= " padding-top: 60px;\n"; $fileReplace .= " }\n"; $fileReplace .= " </style>\n"; $fileReplace .= " <link href=\"{{ url('bootstrap/css/bootstrap-theme.min.css') }}\" rel=\"stylesheet\">\n"; $fileReplace .= "<!--[css]-->\n"; $this->fileContents = str_replace("<!--[css]-->", $fileReplace, $this->fileContents); $this->fileContents = str_replace("<!--[javascript]-->", "<script src=\"{{ url('bootstrap/js/bootstrap.min.js') }}\"></script>\n<!--[javascript]-->", $this->fileContents); } else { if ($this->configSettings['downloads']['foundation']) { $ch = curl_init("http://foundation.zurb.com/cdn/releases/foundation-5.2.2.zip"); $fp = fopen("public/foundation.zip", "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_exec($ch); curl_close($ch); fclose($fp); $zip = zip_open("public/foundation.zip"); if ($zip) { while ($zip_entry = zip_read($zip)) { $foundationFile = "public/" . zip_entry_name($zip_entry); $foundationDir = dirname($foundationFile); $this->fileCreator->createDirectory($foundationDir); $fp = fopen("public/" . zip_entry_name($zip_entry), "w"); if (zip_entry_open($zip, $zip_entry, "r")) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); fwrite($fp, "{$buf}"); zip_entry_close($zip_entry); fclose($fp); } } zip_close($zip); \File::delete('public/index.html'); \File::delete('public/robots.txt'); \File::delete('humans.txt'); \File::delete('foundation.zip'); \File::deleteDirectory('public/js/foundation'); \File::deleteDirectory('public/js/vendor'); \File::move('public/js/foundation.min.js', 'public/js/foundation.js'); } $fileReplace = " <link href=\"{{ url ('css/foundation.min.css') }}\" rel=\"stylesheet\">\n<!--[css]-->"; $this->fileContents = str_replace("<!--[css]-->", $fileReplace, $this->fileContents); $this->fileContents = str_replace("<!--[javascript]-->", "<script src=\"{{ url ('/js/foundation.js') }}\"></script>\n<!--[javascript]-->", $this->fileContents); } } }