themeTestImagePath = '../public/theme/images/global/'; $this->themeTestCSSPath = '../public/theme/css/theme/'; $this->themeTestScriptsPath = '../public/theme/scripts/theme/'; $this->themes = $themeService; $this->currentTheme = $this->themes->getCurrentTheme(); } public function getCurrentTheme() { return $this->currentTheme; } public function moveToTheme() { //get current theme foreach ( new \DirectoryIterator('../content/themes/' . $this->currentTheme . '/assets/images/global/') as $file ) { if ($file->isDot()) { continue; } //make theme directory if not present if (!is_dir($this->themeTestImagePath)) { mkdir($this->themeTestImagePath, 0755, true); } if (!is_file($this->themeTestImagePath . $file->getFileName())) { copy( '../content/themes/' . $this->currentTheme . '/assets/images/global/' . $file->getFileName(), $this->themeTestImagePath . $file->getFileName() ); } else { //image is already there, so chill } //print $file->getFilename() . "\n"; } //clear test theme css and script directories $styles = glob($this->themeTestCSSPath . '*'); // get all file names foreach ($styles as $file) { // iterate files if (is_file($file)) { unlink($file); // delete file } } $scripts = glob($this->themeTestScriptsPath . '*'); // get all file names foreach ($scripts as $file) { // iterate files if (is_file($file)) { unlink($file); // delete file } } // //copy theme assets to public $newcss = glob('../content/themes/' . $this->currentTheme . '/assets/css/*'); if (!is_dir($this->themeTestCSSPath)) { mkdir($this->themeTestCSSPath, 0755, true); } foreach ($newcss as $file) { // iterate files if (is_file($file)) { $path = explode('/', $file); copy($file, $this->themeTestCSSPath . $path[6]); } } $newjs = glob('../content/themes/' . $this->currentTheme . '/assets/scripts/*'); if (!is_dir($this->themeTestScriptsPath)) { mkdir($this->themeTestScriptsPath, 0755, true); } foreach ($newjs as $file) { // iterate files if (is_file($file)) { $path = explode('/', $file); copy($file, $this->themeTestScriptsPath . $path[6]); } } } }