/**
  * @param string $dir
  */
 protected function removeFiles($dir)
 {
     $files = $this->filesystem->glob($dir . '/*');
     foreach ($files as $file) {
         $this->filesystem->delete($file);
     }
 }
Example #2
0
 /**
  * Find the extensions.
  *
  * @param  array $paths
  * @return array
  */
 public function findExtensions(array $paths)
 {
     $files = array();
     // Iterate over the paths.
     foreach ($paths as $path) {
         // Find the extension files.
         $found = $this->filesystem->glob($path . '/*/*/extension.php');
         // Check if we found some files.
         if (is_array($found)) {
             // Merge the files.
             $files = array_merge($files, $found);
         }
     }
     $extensions = array();
     // Iterate over the files.
     foreach ($files as $file) {
         // Get the extension attributes.
         $attributes = $this->filesystem->getRequire($file);
         // Check if the attributes are valid.
         if (is_array($attributes) && isset($attributes['slug'])) {
             // Initialise the extension class.
             $extensions[$attributes['slug']] = new Extension(dirname($file), $attributes);
         }
     }
     return $extensions;
 }
Example #3
0
 /**
  * {@inheritDoc}
  */
 public function findExtensionsInPath($path)
 {
     $extensions = $this->filesystem->glob($path . '/*/*/extension.php');
     if ($extensions === false) {
         return array();
     }
     return $extensions;
 }
 /**
  * @return void
  */
 public function fire()
 {
     $statics = $this->files->glob($this->notadd->publicPath() . DIRECTORY_SEPARATOR . 'cache' . '/*');
     foreach ($statics as $static) {
         $this->files->deleteDirectory($static);
     }
     $this->info('Static files cleared!');
 }
Example #5
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $views = $this->files->glob($this->laravel['config']['view.compiled'] . '/*');
     foreach ($views as $view) {
         $this->files->delete($view);
     }
     $this->info('Compiled views cleared!');
 }
Example #6
0
 /**
  * Get an array of paths to a given file.
  * @param type $path
  */
 public function files($filepath)
 {
     $out = array();
     foreach ($this->modules as $dir) {
         $files = $this->fs->glob(app_path() . "/../{$dir}/{$filepath}");
         $out = array_merge($out, $files);
     }
     return $out;
 }
 /**
  * Figure out what files are to be formatted
  *
  * @return string
  */
 private function determineFiles()
 {
     // NOTE: Since we are using file, then it exist, but may not be set
     if ($this->input->hasOption('file') && $this->input->getOption('file')) {
         $this->output->writeln("<info>Formatting " . $this->input->getOption('file') . "</info>");
         return $this->input->getOption('file');
     }
     $this->output->writeln("<info>Formatting code in " . $this->generator->generatedDirectory('*.php', false) . "</info>");
     // Has a default, so don't have to check for existence
     return implode(" ", $this->files->glob($this->generator->generatedDirectory('*.php', false)));
 }
 /**
  * Runs through the files int the API src dir, and pulls the public methods out
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setInputOutput($input, $output);
     $output->writeln("<info>Adding type hints to generated code...</info>");
     $this->generator->setAndMakeApiDirectory($this->input->getOption('directory'), false, $this->output);
     // Grab each file in the folder
     foreach ($this->files->glob($this->generator->generatedDirectory('*.php', false)) as $file) {
         $output->writeln("<comment>Adding type hints to " . $file . "</comment>");
         $this->type_hinter->process($file);
     }
 }
Example #9
0
 /**
  * @return void
  */
 public function fire()
 {
     $path = $this->laravel['config']['view.compiled'];
     if (!$path) {
         throw new RuntimeException('View path not found.');
     }
     foreach ($this->files->glob("{$path}/*") as $view) {
         $this->files->delete($view);
     }
     $this->info('Compiled views cleared!');
 }
Example #10
0
 /**
  * 初始化匯入資料.
  *
  * @return void
  */
 protected function init()
 {
     $dir = $this->option('dir') ? realpath($this->option('dir')) : false;
     if (false !== $dir && $this->filesystem->isDirectory($dir)) {
         $this->files = array_merge($this->files, $this->filesystem->glob(file_build_path($dir, '*.html')));
     }
     $file = $this->option('file') ? realpath($this->option('file')) : false;
     if (false !== $file && ends_with($file, '.html') && $this->filesystem->isFile($file)) {
         $this->files[] = $file;
     }
 }
Example #11
0
 /**
  * fire.
  *
  * @method fire
  */
 public function fire()
 {
     $root = $this->getLaravel()->basePath();
     $directories = ['.git', 'node_modules', 'vendor/**/**/.git', 'vendor/**/**/node_modules', 'vendor/**/**/vendor', 'vendor/**/**/Tests', 'vendor/**/**/tests', 'vendor/**/**/Test', 'vendor/**/**/test'];
     (new Collection($directories))->map(function ($directory) use($root) {
         return $this->filesystem->glob($root . '/' . $directory, GLOB_ONLYDIR);
     })->collapse()->each(function ($directory) {
         $this->filesystem->deleteDirectory($directory);
         $this->error('delete directory: ' . $directory);
     });
 }
Example #12
0
 /**
  * @return mixed
  */
 private function findPlugins()
 {
     $directories = $this->filesystem->directories($this->config->get('plugins.path'));
     return Collection::make($directories)->reduce(function (&$initial, $directory) {
         $files = $this->filesystem->glob($directory . '/*.php');
         foreach ($files as $file) {
             $plugin = $this->get_plugin_data($file);
             if (!empty($plugin['Title']) && !empty($plugin['Version'])) {
                 $plugin['Name'] = basename($directory);
                 $initial[] = $this->transformWPPluginToPlugin($plugin);
             }
         }
         return $initial;
     }, []);
 }
 /**
  * Get all of the names of the Translations files from an array of Paths.
  * Returns [ 'translationkeyprefix' => 'filepath' ]
  * @param array $paths
  * @return array
  */
 protected function getTranslationFilenamesFromPaths(array $paths)
 {
     $files = [];
     $locales = config('laravellocalization.supportedLocales');
     foreach ($paths as $hint => $path) {
         foreach ($locales as $locale => $language) {
             foreach ($this->finder->glob("{$path}/{$locale}/*.php") as $file) {
                 $category = str_replace(["{$path}/", ".php", "{$locale}/"], "", $file);
                 $category = str_replace("/", ".", $category);
                 $category = !is_int($hint) ? "{$hint}::{$category}" : $category;
                 $files[$locale][$category] = $file;
             }
         }
     }
     return $files;
 }
 /**
  * Decompress archive and delete non-used files.
  *
  * @return void
  */
 protected function decompress()
 {
     $directory = dirname($this->archivePath);
     $this->externalCommand("tar zxf {$this->archivePath}", $directory);
     $specifics = [file_build_path($directory, 'index.html'), file_build_path($directory, 'all_english.html'), $this->archivePath];
     $this->filesystem->delete(array_merge($this->filesystem->glob(file_build_path($directory, '*e.html')), $this->getOldFiles($directory), $specifics));
 }
Example #15
0
 /**
  * cleanupVendor.
  *
  * @method cleanupVendor
  *
  * @param string $vendorDirectory
  */
 public function cleanupVendor($vendorDirectory)
 {
     $rules = static::getRules();
     foreach ($rules as $packageDir => $rules) {
         $packageDir = $vendorDirectory . '/' . $packageDir;
         if ($this->filesystem->isDirectory($packageDir) === false) {
             continue;
         }
         foreach ((array) $rules as $part) {
             $patterns = explode(' ', trim($part));
             foreach ($patterns as $pattern) {
                 $this->delete($this->filesystem->glob($packageDir . '/' . $pattern));
             }
         }
     }
 }
Example #16
0
 /**
  * Delete some default files.
  *
  * @return void
  */
 protected function deleteDefaultFiles()
 {
     foreach ($this->files as $key => $file) {
         $this->finder->delete(base_path($key), $file);
     }
     $this->finder->delete($this->finder->glob(base_path('database/migrations/*create_users_table.php')));
     $this->finder->delete($this->finder->glob(base_path('database/migrations/*create_password_resets_table.php')));
 }
 /**
  * Get all of the migration files in a given path.
  *
  * @param  string  $path
  * @return array
  */
 public function getMigrationFiles($path)
 {
     $files = $this->files->glob($path . '/*_*.php');
     // Once we have the array of files in the directory we will just remove the
     // extension and take the basename of the file which is all we need when
     // finding the migrations that haven't been run against the databases.
     if ($files === false) {
         return array();
     }
     $files = array_map(function ($file) {
         return str_replace('.php', '', basename($file));
     }, $files);
     // Once we have all of the formatted file names we will sort them and since
     // they all start with a timestamp this should give us the migrations in
     // the order they were actually created by the application developers.
     sort($files);
     return $files;
 }
Example #18
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // get random file name and file extension
     $path = temp_path(str_random());
     $originalExtension = substr(strrchr($this->argument('url'), '.'), 1);
     // download file and store it
     $this->info('Downloading the file...' . PHP_EOL);
     $response = $this->client->get($this->argument('url'), ['verify' => storage_path('app/wildcard_ccu_edu_tw')]);
     $this->filesystem->put("{$path}.{$originalExtension}", $response->getBody()->getContents());
     // extract the file
     $this->info('Extracting the file...' . PHP_EOL);
     (new PharData("{$path}.{$originalExtension}"))->decompress();
     (new PharData("{$path}.tar"))->extractTo(temp_path());
     // delete non-used files
     $this->info('Deleting non-used the file...' . PHP_EOL);
     $this->filesystem->delete(["{$path}.{$originalExtension}", "{$path}.tar", temp_path('index.html')]);
     $this->filesystem->delete($this->filesystem->glob(temp_path('*e.html')));
     $this->info('Succeed!');
 }
Example #19
0
 /**
  * Returns an array of log file paths.
  *
  * @return array
  */
 private function getLogFileList()
 {
     if ($this->filesystem->isDirectory($this->path)) {
         $logPath = sprintf('%s%s*.log', $this->path, DIRECTORY_SEPARATOR);
         if ($this->getDate() != 'none') {
             $logPath = sprintf('%s%slaravel-%s.log', $this->path, DIRECTORY_SEPARATOR, $this->getDate());
         }
         return $this->filesystem->glob($logPath);
     }
 }
Example #20
0
 /**
  * Compile views.
  *
  * @param  array  $paths
  * @param  string $storagePath
  * @return $this
  */
 public function compileViews(array $paths, $storagePath)
 {
     $this->makeDestination($storagePath);
     $compiler = new BladeCompiler($this->files, $storagePath);
     foreach ($paths as $path) {
         $files = $this->files->glob(realpath($path) . '/{,**/}*.php', GLOB_BRACE);
         foreach ($files as $file) {
             if (!Str::endsWith(strtolower($file), '.blade.php')) {
                 continue;
             }
             $compiler->setPath($file);
             $contents = $this->parseToken($this->files->get($file));
             $contents = $compiler->compileString($contents);
             $compiledPath = $compiler->getCompiledPath($compiler->getPath());
             $this->files->put($compiledPath . '.php', $contents);
         }
     }
     return $this;
 }
Example #21
0
 /**
  * Get all of the migration files in a given path.
  *
  * @param  string|array  $paths
  * @return array
  */
 public function getMigrationFiles($paths)
 {
     return Collection::make($paths)->flatMap(function ($path) {
         return $this->files->glob($path . '/*_*.php');
     })->filter()->sortBy(function ($file) {
         return $this->getMigrationName($file);
     })->values()->keyBy(function ($file) {
         return $this->getMigrationName($file);
     })->all();
 }
Example #22
0
 /**
  * Get all of the migration files in a given path.
  *
  * @param $path
  *
  * @return array
  */
 public function getMappingFiles($path)
 {
     $files = $this->files->glob($path . '/*_*.php');
     if ($files === false) {
         return [];
     }
     $files = array_map(function ($file) {
         return str_replace('.php', '', basename($file));
     }, $files);
     return $files;
 }
 /**
  * Pull the signatures from the files
  *
  * @return array
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 private function extractSignatures()
 {
     $signatures = [];
     foreach ($this->files->glob($this->generator->generatedDirectory('*Api.php', false)) as $file) {
         $this->output->writeln("<comment>Building method signature(s) for {$file}</comment>");
         $signatures += $this->extractor->process($this->files->get($file));
     }
     // Filter out nulls
     $signatures = array_filter($signatures);
     return $signatures;
 }
Example #24
0
 /**
  * Scans the modules directory for modules and returns an array
  * of Module objects.
  * @return array
  */
 protected function scanModulesDirectory()
 {
     $modules = [];
     $path = base_path('Modules');
     $files = $this->filesystem->glob($path . '/*/module.json');
     foreach ($files as $file) {
         $moduleName = dirname($file);
         $moduleData = $this->getJsonContents($file);
         $modules[] = $this->createModuleObject($moduleData->name);
     }
     return $modules;
 }
Example #25
0
 /**
  * fire.
  */
 public function fire()
 {
     $path = $this->argument('path');
     $lines = $this->option('lines');
     if (empty($path) === false) {
         $path = $this->getLaravel()->basePath() . '/' . $path;
     } else {
         $path = $this->getLaravel()->storagePath();
         $files = array_filter($this->filesystem->glob($path . '/logs/*.log'), function ($file) {
             return is_file($file);
         });
         usort($files, function ($a, $b) {
             $aTime = filectime($a);
             $bTime = filectime($b);
             if ($aTime == $bTime) {
                 return 0;
             }
             return $aTime < $bTime ? -1 : 1;
         });
         $path = $files[0];
     }
     $this->readLine($path, $lines);
 }
Example #26
0
 /**
  * Get all of the migration files in a given path.
  *
  * @param  string $path
  * @return array
  */
 public function getMigrationFiles($path)
 {
     $files = $this->files->glob($path . '/*_*.php');
     if ($files === false) {
         return [];
     }
     $files = array_map(function ($file) {
         return str_replace('.php', '', basename($file));
     }, $files);
     // Once we have all of the formatted file names we will sort them and since
     // they all start with a timestamp this should give us the migrations in
     // the order they were actually created by the application developers.
     sort($files);
     return $files;
 }
Example #27
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $seedsPath = APP_ROOT . 'db' . DS . 'seeds';
     $filesystem = new Filesystem();
     $files = $filesystem->glob($seedsPath . '/*.php');
     foreach ($files as $file) {
         $cleanName = explode('/', $file);
         $cleanName = explode('.', end($cleanName));
         $cleanName = reset($cleanName);
         require $file;
         $output->writeln("Seeded: " . $cleanName);
     }
     $output->writeln('');
     $output->writeln('Seeded!');
 }
 /**
  * Read directory for the migration files
  *
  * @return array
  */
 protected function readMigrationFiles()
 {
     $files = $this->files->glob(base_path('database/migrations') . '/*_*.php');
     if ($files === false) {
         return [];
     }
     # Get the basenames without extension
     $files = array_map(function ($file) {
         return str_replace('.php', '', basename($file));
     }, $files);
     # Only valid migration names 0000_00_00_000000_name_in_snake_case
     $files = array_filter($files, function ($name) {
         return preg_match($this->nameRegex, $name) === 1;
     });
     rsort($files);
     return $files;
 }
Example #29
0
 /**
  * Delete matching files from the wildcard glob search except the ignored file.
  * 
  * @param  string  $wildcard
  * @param  array|string  $ignored
  * @return void
  */
 protected function deleteMatchingFiles($wildcard, $ignored = null)
 {
     if (is_array($files = $this->files->glob($wildcard))) {
         foreach ($files as $path) {
             if (!is_null($ignored)) {
                 // Spin through each of the ignored assets and if the current file path ends
                 // with any of the ignored asset paths then we'll skip this asset as it
                 // needs to be kept.
                 foreach ((array) $ignored as $ignore) {
                     if (ends_with($path, $ignore)) {
                         continue 2;
                     }
                 }
             }
             $this->files->delete($path);
         }
     }
 }
Example #30
0
 /**
  * Takes a source with an array of relative path patterns, finds
  * the corresponding files in the filesystem.
  *
  * @param  string  $source
  * @param  array   $patterns
  * @param  bool    $parentDir
  * @return array   $paths
  */
 protected function manipulatePathResults($source, array $patterns, $parentDir = true)
 {
     $paths = array();
     // Now we will glob our filesystem for each pattern
     foreach ($patterns as $pattern) {
         if ($results = $this->filesystem->glob(rtrim($source, '/') . $pattern, GLOB_BRACE)) {
             $paths = array_merge($paths, array_map(function ($result) use($parentDir) {
                 // Remove the parent directory if needed
                 if ($parentDir === true) {
                     $result = dirname($result);
                 }
                 return $result;
             }, $results));
         }
     }
     // We'll sort the paths now so they are processed systematically
     sort($paths);
     // It is likely that our glob patterns may have duplicated paths.
     // Let's ensure that's not the case by returning only unique paths.
     return array_unique($paths);
 }