/** * generate * * @param string $stubDir * @param string $destDir * @param array $files * @param array $vars * @return $this * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ public function generate($stubDir, $destDir, array $files = [], array $vars = []) { foreach ($files as $stubFile => $destFile) { foreach (array_dot($vars) as $key => $val) { $destFile = Str::replace($destFile, '{{' . $key . '}}', $val); } $stubPath = Path::join($stubDir, $stubFile); $destPath = Path::join($destDir, $destFile); $destDirPath = Path::getDirectory($destPath); if (!$this->files->exists($destDirPath)) { $this->files->makeDirectory($destDirPath, 0755, true); } $rendered = $this->render($this->files->get($stubPath), $vars); $this->files->put($destPath, $rendered); } return $this; }
/** * getViewsPath * * @param null $path * @return string */ public function getViewsPath($dirName) { return realpath(Str::replace($this->viewsPath, '{dirName}', $dirName)); }