Example #1
0
 /**
  * Extension list.
  *
  * @return \Illuminate\Support\Collection
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function getExtensions()
 {
     if ($this->extensions->isEmpty()) {
         if ($this->files->isDirectory($this->getExtensionPath()) && !empty($vendors = $this->files->directories($this->getExtensionPath()))) {
             collect($vendors)->each(function ($vendor) {
                 if ($this->files->isDirectory($vendor) && !empty($directories = $this->files->directories($vendor))) {
                     collect($directories)->each(function ($directory) {
                         if ($this->files->exists($file = $directory . DIRECTORY_SEPARATOR . 'composer.json')) {
                             $package = new Collection(json_decode($this->files->get($file), true));
                             if (Arr::get($package, 'type') == 'notadd-extension' && ($name = Arr::get($package, 'name'))) {
                                 $extension = new Extension($name);
                                 $extension->setAuthor(Arr::get($package, 'authors'));
                                 $extension->setDescription(Arr::get($package, 'description'));
                                 if ($entries = data_get($package, 'autoload.psr-4')) {
                                     foreach ($entries as $namespace => $entry) {
                                         $extension->setEntry($namespace . 'Extension');
                                     }
                                 }
                                 $this->extensions->put($directory, $extension);
                             }
                         }
                     });
                 }
             });
         }
     }
     return $this->extensions;
 }
Example #2
0
 /**
  * Creates the modules directory if it doesn't already exist.
  */
 protected function createModulesDir()
 {
     $path = base_path('Modules');
     if (!$this->filesystem->isDirectory($path)) {
         $this->filesystem->makeDirectory($path);
     }
 }
 /**
  * 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);
     }
 }
Example #4
0
 /**
  * Publishes all themes files in the given package to their
  * respective themes.
  *
  * @param  string  $source
  * @return bool
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  */
 public function publish($source)
 {
     if (!$this->filesystem->isDirectory($source)) {
         throw new InvalidArgumentException("Source [{$source}] does not exist.");
     }
     $paths = $this->getThemeSourcePaths($source);
     foreach ($paths as $path) {
         $relativePath = str_replace(str_finish($source, '/'), '', $path);
         $slugs = $this->extractSlugsFromPath($relativePath);
         // If we cannot resolve a theme, the user has probably got assets
         // for a theme which isn't in this installation. Let's not punish
         // them for supporting more than the installed themes, we'll just
         // let them know we've skipped it.
         try {
             $theme = $this->getThemeForSlugs($slugs);
         } catch (RuntimeException $e) {
             $this->note(sprintf('Couln\'t load theme for slug(s) [%s] in source [%s], skipping.', implode(', ', $slugs), $source));
             continue;
         }
         $mappings = $this->getCopyMappings($path, $theme);
         foreach ($mappings as $_source => $destination) {
             $success = $this->filesystem->copyDirectory($_source, $destination);
             if (!$success) {
                 throw new RuntimeException("Failed to publish [{$_source}] to [{$destination}].");
             }
         }
     }
     return true;
 }
 protected function createDirectory()
 {
     $directory = $this->getDirectory();
     if (!$this->files->isDirectory($directory)) {
         $this->files->makeDirectory($directory, 0755, true);
     }
 }
 /**
  * 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 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;
 }
Example #8
0
 /**
  * Modules of installed or not installed.
  *
  * @param bool $installed
  *
  * @return \Illuminate\Support\Collection
  */
 public function getModules($installed = false)
 {
     if ($this->modules->isEmpty()) {
         if ($this->files->isDirectory($this->getModulePath()) && !empty($directories = $this->files->directories($this->getModulePath()))) {
             (new Collection($directories))->each(function ($directory) use($installed) {
                 if ($this->files->exists($file = $directory . DIRECTORY_SEPARATOR . 'composer.json')) {
                     $package = new Collection(json_decode($this->files->get($file), true));
                     if (Arr::get($package, 'type') == 'notadd-module' && ($name = Arr::get($package, 'name'))) {
                         $module = new Module($name);
                         $module->setAuthor(Arr::get($package, 'authors'));
                         $module->setDescription(Arr::get($package, 'description'));
                         if ($installed) {
                             $module->setInstalled($installed);
                         }
                         if ($entries = data_get($package, 'autoload.psr-4')) {
                             foreach ($entries as $namespace => $entry) {
                                 $module->setEntry($namespace . 'ModuleServiceProvider');
                             }
                         }
                         $this->modules->put($directory, $module);
                     }
                 }
             });
         }
     }
     return $this->modules;
 }
 /**
  * @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!');
 }
 /**
  * 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);
     }
 }
 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;
 }
 /**
  * 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);
     }
 }
Example #13
0
 /** @test */
 public function it_should_generate_module_folder()
 {
     // Run
     $this->scaffoldModuleWithEloquent();
     // Assert
     $this->assertTrue($this->finder->isDirectory($this->testModulePath));
     $this->cleanUp();
 }
 public function tearDown()
 {
     $this->finder->deleteDirectory($this->modulePath);
     if ($this->finder->isDirectory(base_path('modules/ModuleName'))) {
         $this->finder->deleteDirectory(base_path('modules/ModuleName'));
     }
     parent::tearDown();
 }
 /**
  * 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 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);
 }
Example #17
0
 /**
  * Check/Create cache directory
  */
 private function checkCacheDirectory()
 {
     if ($this->cachePath) {
         if (!$this->files->isDirectory($this->cachePath)) {
             $this->files->makeDirectory($this->cachePath);
         }
     }
 }
 /**
  * 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);
     }
 }
Example #19
0
 /**
  * Setup oven configurator
  *
  * @param string $recipePath
  * @return void
  */
 public function setup($recipePath)
 {
     $directory = $this->getDirectoryPath();
     if (!$this->filesystem->isDirectory($directory)) {
         $this->buildConfig();
     }
     $this->setConfigPath($recipePath);
 }
 /**
  * Execute the console command.
  *
  * @param Filesystem $filesystem
  * @return mixed
  */
 public function handle(Filesystem $filesystem)
 {
     $this->filesystem = $filesystem;
     $scaffoldsPath = __DIR__ . '/../Etc/scaffolds/';
     // component info
     $componentTitle = $this->ask('Enter component name');
     $componentDescription = $this->ask('Enter component description');
     $componentIcon = $this->ask('Enter component icon (ex. fa fa-home)');
     $componentNamespace = $this->formatToComponentNamespace($componentTitle);
     $componentUrl = $this->formatToComponentUrl($componentTitle);
     $backendPath = app_path() . '/Backend';
     $componentPath = $backendPath . '/Components/' . $componentNamespace;
     if (!$this->filesystem->isDirectory($backendPath)) {
         $this->filesystem->makeDirectory($backendPath);
     }
     if (!$this->filesystem->isDirectory($backendPath . '/Components')) {
         $this->filesystem->makeDirectory($backendPath . '/Components');
     }
     if ($this->filesystem->isDirectory($componentPath)) {
         $this->error('Component already exist.');
         exit;
     }
     // create necessary component directories
     $this->filesystem->makeDirectory($componentPath);
     $this->filesystem->makeDirectory($componentPath . '/Controllers');
     $this->filesystem->makeDirectory($componentPath . '/Views');
     // process scaffolds
     $componentScaffold = $this->filesystem->get($scaffoldsPath . 'Component');
     $controllerScaffold = $this->filesystem->get($scaffoldsPath . 'Controller');
     $viewScaffold = $this->filesystem->get($scaffoldsPath . 'view');
     $routesScaffold = $this->filesystem->get($scaffoldsPath . 'routes');
     $this->comment(PHP_EOL . 'Creating component...' . PHP_EOL);
     $componentScaffold = str_replace('{{componentNamespace}}', $componentNamespace, $componentScaffold);
     $componentScaffold = str_replace('{{componentTitle}}', $componentTitle, $componentScaffold);
     $componentScaffold = str_replace('{{componentDescription}}', $componentDescription, $componentScaffold);
     $componentScaffold = str_replace('{{componentIcon}}', $componentIcon, $componentScaffold);
     $componentScaffold = str_replace('{{componentUrl}}', $componentUrl, $componentScaffold);
     $this->filesystem->put($componentPath . '/Component.php', $componentScaffold);
     $controllerScaffold = str_replace('{{componentNamespace}}', $componentNamespace, $controllerScaffold);
     $controllerScaffold = str_replace('{{componentTitle}}', $componentTitle, $controllerScaffold);
     $controllerScaffold = str_replace('{{componentDescription}}', $componentDescription, $controllerScaffold);
     $controllerScaffold = str_replace('{{componentIcon}}', $componentIcon, $controllerScaffold);
     $controllerScaffold = str_replace('{{componentUrl}}', $componentUrl, $controllerScaffold);
     $this->filesystem->put($componentPath . '/Controllers/' . $componentNamespace . 'Controller.php', $controllerScaffold);
     $viewScaffold = str_replace('{{componentNamespace}}', $componentNamespace, $viewScaffold);
     $viewScaffold = str_replace('{{componentTitle}}', $componentTitle, $viewScaffold);
     $viewScaffold = str_replace('{{componentDescription}}', $componentDescription, $viewScaffold);
     $viewScaffold = str_replace('{{componentIcon}}', $componentIcon, $viewScaffold);
     $viewScaffold = str_replace('{{componentUrl}}', $componentUrl, $viewScaffold);
     $this->filesystem->put($componentPath . '/Views/index.blade.php', $viewScaffold);
     $routesScaffold = str_replace('{{componentNamespace}}', $componentNamespace, $routesScaffold);
     $routesScaffold = str_replace('{{componentTitle}}', $componentTitle, $routesScaffold);
     $routesScaffold = str_replace('{{componentDescription}}', $componentDescription, $routesScaffold);
     $routesScaffold = str_replace('{{componentIcon}}', $componentIcon, $routesScaffold);
     $routesScaffold = str_replace('{{componentUrl}}', $componentUrl, $routesScaffold);
     $this->filesystem->put($componentPath . '/routes.php', $routesScaffold);
     $this->info(PHP_EOL . 'Component successfully created!' . PHP_EOL);
 }
Example #21
0
 /**
  * Check/Create cache directory
  */
 private function checkCacheDirectory()
 {
     $cachePath = $this->config->get('purifier.cachePath');
     if ($cachePath) {
         if (!$this->files->isDirectory($cachePath)) {
             $this->files->makeDirectory($cachePath);
         }
     }
 }
Example #22
0
 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/*']);
 }
 protected function copyBlueprint($file)
 {
     $blueprintPath = $this->getBlueprint($file);
     if ($this->file->isDirectory($blueprintPath)) {
         $this->file->copyDirectory($this->getBlueprint($file), base_path($file));
     } else {
         $this->file->copy($this->getBlueprint($file), base_path($file));
     }
 }
 /**
  * Get documentation by version and filename.
  *
  * @param  string  $path
  * @param  string  $filename
  *
  * @return array
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function getDocumentation($path, $filename)
 {
     if ($this->files->isDirectory("{$path}/src/{$filename}")) {
         $filename = "{$filename}/index";
     }
     $toc = "{$path}/src/contents.md";
     $document = "{$path}/src/{$filename}.md";
     return [$this->getTableOfContent($toc), $this->getBodyContent($document)];
 }
Example #25
0
 /**
  * Function to write out the template to
  * the given file if it is indeed a file, and as
  * the default template name at the given path
  * if it is a directory.
  * 
  * @return string the file that was witten
  */
 public function write()
 {
     if ($this->filesystem->isDirectory($this->path)) {
         $file = implode(DIRECTORY_SEPARATOR, [$this->path, $this->default_tpl]);
     } else {
         $file = $this->path;
     }
     $this->filesystem->put($file, $this->getStructureJson());
     return $file;
 }
Example #26
0
 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}'..");
         }
     }
 }
Example #27
0
 /**
  * @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();
     }
 }
 protected function createDirectory()
 {
     // Directory.
     $directory = $this->getDirectory();
     // Check if the directory exists.
     if (!$this->files->isDirectory($directory)) {
         // Create the directory if not.
         $this->files->makeDirectory($directory, 0755, true);
     }
 }
Example #29
0
 /**
  * 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();
 }
 /**
  * @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;
 }