private function createTmpDir($dir) { if (!$this->filesystem->exists($dir)) { $this->filesystem->makeDirectory($dir, 0755, true); } return true; }
/** * @param Request $request * @return mixed * @throws \Exception * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ public function createMissingController(Request $request) { $namespace = $request->namespace; $controller = $request->controller; $module = $request->module; //Get controllers folder $controllersDir = $this->getMainControllerPath(); //Get controller path for new controller $newControllerDir = $this->getControllerPath($namespace, $module); //Get controller namespace $controllerNamespace = $this->getMainControllerNamespace(); //Get namespace for the new controller $newControllerNamespace = $this->getControllerNamespace($namespace, $module); //Get the file $file = $this->getFileLocation($namespace, $module, $controller); $controllerClass = studly_case($controller . 'Controller'); //Check if file exists $fileExists = $this->fileExists($file); //Check if is dir if (!$this->fs->isDirectory($newControllerDir)) { $this->fs->makeDirectory($newControllerDir, 0755, true, true); } //If file doesnt exist, create the file if (!$fileExists) { $template = $this->builder->setNamespace($newControllerNamespace)->setTemplate($this->fs->get($this->config['templates']['controller']))->setClassName(studly_case($controllerClass))->setUses(Request::class)->buildController(); //Store the file $this->fs->put($file, $template); //Call the created controller return app($newControllerNamespace . '\\' . $controllerClass)->index(); } throw new \Exception('File exists! I don\'t want to override it!'); }
protected function createDirectory() { $directory = $this->getDirectory(); if (!$this->files->isDirectory($directory)) { $this->files->makeDirectory($directory, 0755, true); } }
/** * Build the directory for the view if necessary. * * @param $path */ private function makeDirectory($path) { $dir = dirname($path); if (!$this->files->isDirectory($dir)) { $this->files->makeDirectory($dir, 0777, true, true); } }
public function save($item, $value, $environment, $group, $namespace = null) { $path = DIR_APPLICATION . '/config/generated_overrides'; if (!$this->files->exists($path)) { $this->files->makeDirectory($path, 0777); } elseif (!$this->files->isDirectory($path)) { $this->files->delete($path); $this->files->makeDirectory($path, 0777); } if ($namespace) { $path = "{$path}/{$namespace}"; if (!$this->files->exists($path)) { $this->files->makeDirectory($path, 0777); } elseif (!$this->files->isDirectory($path)) { $this->files->delete($path); $this->files->makeDirectory($path, 0777); } } $file = "{$path}/{$group}.php"; $current = array(); if ($this->files->exists($file)) { $current = $this->files->getRequire($file); } array_set($current, $item, $value); $renderer = new Renderer($current); return $this->files->put($file, $renderer->render()) !== false; }
protected function makeDirectory($path) { if (!($status = $this->files->makeDirectory($path))) { return $this->files->makeDirectory(dirname($path), 0777, true, true); } return $status; }
/** * Make directory. * * @param string $directory * @return void */ protected function makeDir($directory) { if (!$this->files->isDirectory($directory)) { $this->info('Creating directory ' . $directory); $this->files->makeDirectory($directory, 0777, true); } }
public function setUp() { $this->loader = new FileLoader($this->files = new Filesystem()); $this->group = md5(time() . uniqid()); $this->namespace = md5(time() . uniqid()); $this->environment = md5(time() . uniqid()); $path = DIR_APPLICATION . '/config/'; $this->loader->addNamespace($this->namespace, $path . $this->namespace); $paths = array("generated_overrides/{$this->group}.php" => array('non-namespaced' => true, 'override' => true, 'second' => false), "{$this->group}.php" => array('non-namespaced' => true, 'main_group' => true, 'second' => true, 'last' => false), "{$this->environment}.{$this->group}.php" => array('non-namespaced' => true, 'environment' => true, 'last' => true), "generated_overrides/{$this->namespace}/{$this->group}.php" => array('namespaced' => true, 'override' => true, 'second' => false), "{$this->namespace}/{$this->group}.php" => array('namespaced' => true, 'main_group' => true, 'second' => true, 'last' => false), "{$this->namespace}/{$this->environment}.{$this->group}.php" => array('namespaced' => true, 'environment' => true, 'last' => true)); foreach ($paths as $relative_path => $array) { $split = explode('/', $relative_path); $current_path = $path; array_pop($split); foreach ($split as $directory) { $dir = "{$current_path}/{$directory}"; if (!$this->files->exists($dir)) { $this->files->makeDirectory($dir); $this->to_remove[] = $dir; } $current_path = $dir; } $this->to_remove[] = $path . $relative_path; $this->files->put($path . $relative_path, id(new Renderer($array))->render()); } }
/** * Execute the console command. * * @return mixed */ public function fire() { $model = ucfirst($this->argument('model')); $path = $this->option('path'); if (empty($path)) { $path = database_path(config('smart-seeder.seedDir')); } else { $path = base_path($path); } $env = $this->option('env'); if (!empty($env)) { $path .= "/{$env}"; } if (!$this->files->exists($path)) { // mode 0755 is based on the default mode Laravel use. $this->files->makeDirectory($path, 755, true); } $created = date('Y_m_d_His'); $path .= "/seed_{$created}_{$model}Seeder.php"; $fs = $this->files->get(__DIR__ . '/stubs/DatabaseSeeder.stub'); $namespace = rtrim($this->getAppNamespace(), '\\'); $stub = str_replace('{{seeder}}', "seed_{$created}_" . $model . 'Seeder', $fs); $stub = str_replace('{{namespace}}', " namespace {$namespace};", $stub); $stub = str_replace('{{model}}', $model, $stub); $this->files->put($path, $stub); $message = "Seed created for {$model}"; if (!empty($env)) { $message .= " in environment: {$env}"; } $this->line($message); }
/** * Make directory. * * @param string $directory * @return void */ protected function makeDir($directory) { if (!$this->files->isDirectory($this->getPath($directory))) { $this->info('Createing directory ' . $this->getPath($directory)); $this->files->makeDirectory($this->getPath($directory), 0777, true); } }
/** * Create the directory for the controller. * * @param string $controller * @param string $path * @return void */ protected function makeDirectory($controller, $path) { $directory = $this->getDirectory($controller); if (!$this->files->isDirectory($full = $path . '/' . $directory)) { $this->files->makeDirectory($full, 0777, true); } }
/** * Create dir if does not exists ! * * @param $directory * @return bool */ public function makeDir($directory) { if (!$this->filesystem->isDirectory($directory)) { return $this->filesystem->makeDirectory($directory); } return false; }
/** * Check/Create cache directory */ private function checkCacheDirectory() { if ($this->cachePath) { if (!$this->files->isDirectory($this->cachePath)) { $this->files->makeDirectory($this->cachePath); } } }
/** * Create directory for anonymizers. * * @param string $dir */ protected function createDirectory($dir) { if ($this->files->isDirectory($dir)) { $this->error("Directory {$dir} already exists"); return; } $this->files->makeDirectory($dir); }
/** * Creates the module directory and other folders. */ protected function createFolders() { $path = base_path('Modules/' . $this->name); $this->filesystem->makeDirectory($path); foreach ($this->foldersToGenerate as $folder) { $this->filesystem->makeDirectory($path . '/' . $folder); } }
/** * FileCertificateProvider constructor. * * @param Filesystem $filesystem * @param string $filePath */ public function __construct(Filesystem $filesystem, $filePath) { $this->filesystem = $filesystem; $this->filePath = $filePath; if (!$this->filesystem->isDirectory($this->filePath)) { $this->filesystem->makeDirectory($this->filePath); } }
/** * Create the specified folder. * * @param $folder * @param $success * @param $error */ protected function createFolder($folder, $success, $error) { if (!is_dir($folder)) { $this->files->makeDirectory($folder); return $this->console->info($success); } return $this->console->comment($error); }
/** * Write file contents, creating any necessary subdirectories. * * @param string $destination * @param string $content * @return bool */ protected function write($destination, $content) { $directory = dirname($destination); if (!$this->files->exists($directory)) { $this->files->makeDirectory($directory, 0755, true); } return (bool) $this->files->put($destination, $content); }
/** * Create any number of folders * * @param string|array $folders * @return void */ public function folders($folders) { foreach ((array) $folders as $folderPath) { if (!$this->file->exists($folderPath)) { $this->file->makeDirectory($folderPath); } } }
/** * Parse some content. * * @param $content * @return string */ public function parse($content) { if (!$this->files->isDirectory($path = storage_path('framework/views/asset'))) { $this->files->makeDirectory($path); } $this->files->put(storage_path('framework/views/asset/' . (($filename = md5($content)) . '.twig')), $content); return $this->views->make('root::storage/framework/views/asset/' . $filename)->render(); }
/** * Create the file cache directory if necessary. * * @param string $path * @return void */ protected function createCacheDirectory($path) { try { $this->files->makeDirectory(dirname($path), 0777, true, true); } catch (\Exception $e) { // } }
/** * Check/Create cache directory */ private function checkCacheDirectory() { $cachePath = $this->config->get('purifier.cachePath'); if ($cachePath) { if (!$this->files->isDirectory($cachePath)) { $this->files->makeDirectory($cachePath); } } }
public function handle() { $path = $this->repo->repoPath(); if (!$this->fs->isDirectory($path) && !$this->fs->makeDirectory($path, 0755, true)) { throw new \RuntimeException(sprintf("Cannot create repo dir %s", $path)); } Admin::cloneTo($path, $this->repo->url, true, config('git.options')); $this->repo->git()->run('config', ['remote.origin.fetch', 'refs/heads/*:refs/heads/*']); }
/** * Render a string template. * * @param $template * @param array $payload * @return string * @throws \Exception */ function render($template, array $payload = []) { $view = 'templates/' . md5($template); $path = $this->application->getStoragePath($view); if (!$this->files->isDirectory($directory = dirname($path))) { $this->files->makeDirectory($directory, 0777, true); } $this->files->put($path . '.twig', $template); return $this->view->make('storage::' . $view, $payload)->render(); }
private function initStorage() { if (!$this->files->isDirectory($this->alertsStorage)) { if ($this->files->makeDirectory($this->alertsStorage, 0777, true)) { $this->files->put($this->alertsStorage . '.gitignore', "*\n!.gitignore"); } else { throw new Exception("Cannot create directory '{$this->alertsStorage}'.."); } } }
/** * @param $path * @param $stub * @return string */ protected function compileStub($path, $stub) { if (!empty($path) and !$this->file->isDirectory($path)) { $this->file->makeDirectory($path); } //Get the stub $stub = $this->file->get($this->getStubPath($stub)); $this->replaceClassName($stub)->replaceResourceName($stub); return $stub; }
/** * @throws Exceptions\FileTypeNotFoundException * @throws ThemeExistsException */ public function generate() { if ($this->finder->isDirectory($this->themePath($this->options['name']))) { throw new ThemeExistsException("The theme [{$this->options['name']}] already exists"); } $this->finder->makeDirectory($this->themePath($this->options['name'])); foreach ($this->files as $file) { $this->themeGeneratorFactory->make($file, $this->options)->generate(); } }
public function setUp() { parent::setUp(); $this->finder = $this->app['files']; $this->scaffold = $this->app['asgard.theme.scaffold']; if (!$this->finder->isDirectory(base_path("Themes"))) { $this->finder->makeDirectory(base_path("Themes")); } $this->testThemeName = 'TestingTheme'; $this->testThemePath = base_path("Themes/{$this->testThemeName}"); }
/** * Handle the command. * * @param Filesystem $filesystem * @param Application $application * @return string */ public function handle(Filesystem $filesystem, Application $application) { $shared = $this->command->option('shared') ? 'shared' : $application->getReference(); $path = base_path("addons/{$shared}/{$this->vendor}/{$this->slug}-{$this->type}"); $config = "{$path}/resources/config"; $views = "{$path}/resources/views"; $filesystem->makeDirectory($path, 0755, true, true); $filesystem->makeDirectory($views, 0755, true, true); $filesystem->makeDirectory($config, 0755, true, true); return $path; }
/** * Execute the console command. * * @return int */ public function handle() { $rsa = new Crypt_RSA(); $keys = $rsa->createKey(); if (!$this->file->exists(storage_path('app/keys'))) { $this->file->makeDirectory(storage_path('app/keys')); } $this->file->put(storage_path('app/keys/private.pem'), $keys['privatekey']); $this->file->put(storage_path('app/keys/public.pem'), $keys['publickey']); return 0; }