Themsaid\Langman\Manager::files PHP Method

files() public method

ex: ['user' => ['en' => 'user.php', 'nl' => 'user.php']]
public files ( ) : array
return array
    public function files()
    {
        $files = Collection::make($this->disk->allFiles($this->path));
        $filesByFile = $files->groupBy(function ($file) {
            $fileName = $file->getBasename('.' . $file->getExtension());
            if (Str::contains($file->getPath(), 'vendor')) {
                $fileName = str_replace('.php', '', $file->getFileName());
                $packageName = basename(dirname($file->getPath()));
                return "{$packageName}::{$fileName}";
            } else {
                return $fileName;
            }
        })->map(function ($files) {
            return $files->keyBy(function ($file) {
                return basename($file->getPath());
            })->map(function ($file) {
                return $file->getRealPath();
            });
        });
        // If the path does not contain "vendor" then we're looking at the
        // main language files of the application, in this case we will
        // neglect all vendor files.
        if (!Str::contains($this->path, 'vendor')) {
            $filesByFile = $this->neglectVendorFiles($filesByFile);
        }
        return $filesByFile;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $translationFiles = $this->manager->files();
     $this->syncKeysFromFiles($translationFiles);
     $this->syncKeysBetweenLanguages($translationFiles);
     $this->info('Done!');
 }
All Usage Examples Of Themsaid\Langman\Manager::files