/** * Make a single stub. * * @param string $stubName The source filename for the stub. */ public function makeStub($stubName) { if (!isset($this->stubs[$stubName])) { return; } $sourceFile = $this->getSourcePath() . '/' . $stubName; $destinationFile = $this->getDestinationPath() . '/' . $this->stubs[$stubName]; $destinationContent = $this->files->get($sourceFile); /* * Parse each variable in to the destination content and path */ foreach ($this->vars as $key => $var) { $destinationContent = str_replace('{{' . $key . '}}', $var, $destinationContent); $destinationFile = str_replace('{{' . $key . '}}', $var, $destinationFile); } $this->makeDirectory($destinationFile); /* * Make sure this file does not already exist */ if ($this->files->exists($destinationFile) && !$this->option('force')) { throw new Exception('Stop everything!!! This file already exists: ' . $destinationFile); } $this->files->put($destinationFile, $destinationContent); }
/** * Write the contents of a file. * * @param string $path * @param string $contents * @return int * @static */ public static function put($path, $contents, $lock = false) { return \October\Rain\Filesystem\Filesystem::put($path, $contents, $lock); }