public function importTranslations($replace = false)
 {
     $counter = 0;
     foreach ($this->files->directories($this->app->langPath()) as $langPath) {
         $locale = basename($langPath);
         foreach ($this->files->allFiles($langPath) as $file) {
             $group = $file->getRelativePathname();
             $group = str_replace('.' . $this->files->extension($group), '', $group);
             if (in_array($group, $this->config['exclude_groups'])) {
                 continue;
             }
             $translations = \Lang::getLoader()->load($locale, $group);
             if ($translations && is_array($translations)) {
                 foreach (array_dot($translations) as $key => $value) {
                     $value = (string) $value;
                     $translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key));
                     // Check if the database is different then the files
                     $newStatus = $translation->value === $value ? Translation::STATUS_SAVED : Translation::STATUS_CHANGED;
                     if ($newStatus !== (int) $translation->status) {
                         $translation->status = $newStatus;
                     }
                     // Only replace when empty, or explicitly told so
                     if ($replace || !$translation->value) {
                         $translation->value = $value;
                     }
                     $translation->save();
                     $counter++;
                 }
             }
         }
     }
     return $counter;
 }
 public function stepDirectories($directory)
 {
     // Check for markers
     $alteredDirectoryName = $this->checkAndReplace($directory);
     // Move the directory and use the new name
     if ($directory !== $alteredDirectoryName) {
         exec("mv {$directory} {$alteredDirectoryName}");
         $directory = $alteredDirectoryName;
     }
     // For every file in the directory, rename and check content
     foreach ($this->files->allFiles($directory) as $file) {
         // Check for changes
         $alteredFilename = $this->checkAndReplace($file);
         // Rename file if it changed
         if ($file !== $alteredFilename) {
             rename($file, $alteredFilename);
             $file = $alteredFilename;
         }
         // Check the content in file, and rename as well
         file_put_contents($file, $this->checkAndReplace(file_get_contents($file)));
     }
     // Continue down the tree
     foreach ($this->files->directories($directory) as $childDirectory) {
         $this->stepDirectories($childDirectory);
     }
 }
 /** @test */
 public function it_generates_correct_default_migration_file_content()
 {
     $this->artisan('module:make-migration', ['name' => 'something_random_name', 'module' => 'Blog']);
     $migrations = $this->finder->allFiles($this->modulePath . '/Database/Migrations');
     $fileName = $migrations[0]->getRelativePathname();
     $file = $this->finder->get($this->modulePath . '/Database/Migrations/' . $fileName);
     $this->assertEquals($this->expectedDefaultMigrationContent(), $file);
 }
Example #4
0
 /**
  * Get menu files from the specified directory.
  */
 protected function getFiles() : array
 {
     $path = $this->getPath();
     $files = $this->file->allFiles($path);
     if (!$files) {
         throw new MenuFilesNotFound("Menu files have not been found in [{$path}].");
     }
     return $files;
 }
Example #5
0
 public function getAllFiles($languageCode)
 {
     $files = $this->filesystem->allFiles(app_path() . '/lang/' . $languageCode . '/borrower/');
     $filePaths = [];
     foreach ($files as $file) {
         $filePaths[] = $file->getRelativePathname();
     }
     return $filePaths;
 }
 /**
  * Add namespace overrides to configuration.
  *
  * @param $namespace
  * @param $directory
  */
 public function addNamespaceOverrides($namespace, $directory)
 {
     if (!$this->files->isDirectory($directory)) {
         return;
     }
     /* @var SplFileInfo $file */
     foreach ($this->files->allFiles($directory) as $file) {
         $key = trim(str_replace($directory, '', $file->getPath()) . DIRECTORY_SEPARATOR . $file->getBaseName('.php'), DIRECTORY_SEPARATOR);
         // Normalize key slashes.
         $key = str_replace('\\', '/', $key);
         $this->config->set($namespace . '::' . $key, array_replace($this->config->get($namespace . '::' . $key, []), $this->files->getRequire($file->getPathname())));
     }
 }
 /**
  * Execute the console command.
  *
  * @return boolean
  */
 public function fire()
 {
     $this->call('route:clear');
     $routes = $this->getFreshApplicationRoutes();
     if (count($routes) == 0) {
         $this->error("Your application doesn't have any routes.");
         return false;
     }
     $languages = $this->laravel['config']['app.supported_locales'];
     $baseLanguage = $this->laravel['config']['app.locale'];
     foreach ($languages as $language) {
         $fileList[$language] = $this->files->allFiles(sprintf('%s/resources/lang/%s/routes', $this->laravel->basePath(), $language));
     }
     $localizedURIs = [];
     if (!empty($fileList) && is_array($fileList)) {
         /**
          * @var \Symfony\Component\Finder\SplFileInfo $file
          */
         foreach ($fileList as $language => $files) {
             foreach ($files as $file) {
                 $category = $file->getBasename('.php');
                 $localizedURIs[$language][$category] = (include $file->getRealPath());
             }
         }
     }
     $localizedRouteCollection = new RouteCollection();
     foreach ($languages as $language) {
         /**
          * @var \Illuminate\Routing\Route $route
          */
         foreach ($routes as $route) {
             //Keeping only our route information
             $route->prepareForSerialization();
             $action = $route->getAction();
             if (isset($action['category']) && isset($action['as'])) {
                 if (isset($localizedURIs[$language][$action['category']][$action['as']])) {
                     $tmp = clone $route;
                     $tmp->setUri($localizedURIs[$language][$action['category']][$action['as']]);
                     $action['as'] = $language . '.' . $action['as'];
                     $tmp->setAction($action);
                 }
             }
             $localizedRouteCollection->add($tmp);
         }
     }
     $this->files->put($this->laravel->getCachedRoutesPath(), $this->buildRouteCacheFile($localizedRouteCollection));
     $this->info('Localized routes cached successfully!');
     return true;
 }
 /**
  * Get all the translations for all modules on disk
  * @return array
  */
 public function all()
 {
     $allFileTranslations = [];
     $files = $this->finder->allFiles($this->getTranslationsDirectory());
     foreach ($files as $file) {
         $lang = $this->getLanguageFrom($file->getRelativePath());
         $path = $file->getRelativePathname();
         $contents = $this->finder->getRequire($this->getTranslationsDirectory() . '/' . $path);
         $trans = array_dot($contents, $this->getModuleFrom($file->getRelativePath()) . '::' . $this->getFileNameFrom($path) . '.');
         foreach ($trans as $key => $value) {
             $allFileTranslations[$lang][$key] = $value;
         }
     }
     return $allFileTranslations;
 }
 /**
  * Search manual for given string.
  *
  * @param  string $manual
  * @param  string $version
  * @param  string $needle
  * @return array
  */
 public function search($manual, $version, $needle = '')
 {
     $results = [];
     $directory = $this->storagePath . '/' . $manual . '/' . $version;
     $files = preg_grep('/toc\\.md$/', $this->files->allFiles($directory), PREG_GREP_INVERT);
     if (!empty($needle)) {
         foreach ($files as $file) {
             $haystack = file_get_contents($file);
             if (strpos(strtolower($haystack), strtolower($needle)) !== false) {
                 $results[] = ['title' => $this->getPageTitle((string) $file), 'url' => str_replace([$this->config->get('codex.storage_path'), '.md'], '', (string) $file)];
             }
         }
     }
     return $results;
 }
Example #10
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if (!file_exists(base_path('resources/views/team/create.blade.php'))) {
         $this->line("\n\nPlease perform the starter command:\n");
         $this->info("\n\nphp artisan laracogs:starter\n");
         $this->line("\n\nThen one you're able to run the unit tests successfully re-run this command, to bootstrap your app :)\n");
     } else {
         $fileSystem = new Filesystem();
         $files = $fileSystem->allFiles(__DIR__ . '/../Packages/Bootstrap');
         $this->line("\n");
         foreach ($files as $file) {
             $this->line(str_replace(__DIR__ . '/../Packages/Bootstrap/', '', $file));
         }
         $this->info("\n\nThese files will be published\n");
         $result = $this->confirm('Are you sure you want to overwrite any files of the same name?');
         if ($result) {
             $this->copyPreparedFiles(__DIR__ . '/../Packages/Bootstrap/', base_path());
             $this->line("\nMake sure you set the PagesController@dashboard to use the following view:\n");
             $this->comment("'dashboard.main'\n");
             $this->info("Run the following:\n");
             $this->comment("npm install\n");
             $this->comment("gulp\n");
             $this->info("Finished bootstrapping your app\n");
         } else {
             $this->info('You cancelled the laracogs bootstrap');
         }
     }
 }
Example #11
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // 从数据库中获取的ArticleTag集合
     $tags = \App\Model\Tag::all();
     // 初始化博客的路径
     $dir = "/root/blog";
     $file_system = new Filesystem();
     $files = $file_system->allFiles($dir);
     foreach ($files as $file) {
         $file_extension = $file_system->extension($file);
         if ($file_extension != 'md') {
             continue;
         }
         $create_time_stamp = $file_system->lastModified($file);
         $create_time = gmdate("Y-m-d", $create_time_stamp);
         $file_content = $file_system->get($file);
         $file_name = preg_replace('/^.+[\\\\\\/]/', '', $file);
         $file_name = explode(".md", $file_name);
         $blog_name = $file_name[0];
         $last_dir = dirname($file);
         $current_tag_name = preg_replace('/^.+[\\\\\\/]/', '', $last_dir);
         $article_type_id = 0;
         foreach ($tags as $tag) {
             $tag_name = $tag->name;
             if (strcmp($current_tag_name, $tag_name) == 0) {
                 $article_type_id = $tag->id;
                 break;
             }
         }
         $article_id = \App\Model\Article::create(['cate_id' => $article_type_id, 'user_id' => 1, 'title' => $blog_name, 'content' => $file_content, 'tags' => $article_type_id, 'created_at' => $create_time, 'updated_at' => $create_time])->id;
         \App\Model\ArticleStatus::create(['art_id' => $article_id, 'view_number' => 0]);
     }
 }
Example #12
0
 public function templates()
 {
     $path = Config::get('view.paths');
     $fileSystem = new Filesystem();
     $files = $fileSystem->allFiles($path[0] . DIRECTORY_SEPARATOR . Theme::getTheme() . DIRECTORY_SEPARATOR . 'site' . DIRECTORY_SEPARATOR . 'layouts');
     return $files;
 }
Example #13
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if (!file_exists(base_path('resources/views/team/create.blade.php'))) {
         $this->line("\n\nPlease perform the starter command:\n");
         $this->info("\n\nphp artisan laracogs:starter\n");
         $this->line("\n\nThen one you're able to run the unit tests successfully re-run this command, to semantic ui your app :)\n");
     } else {
         $fileSystem = new Filesystem();
         $files = $fileSystem->allFiles(__DIR__ . '/../Packages/Semantic');
         $this->line("\n");
         foreach ($files as $file) {
             $this->line(str_replace(__DIR__ . '/../Packages/Semantic/', '', $file));
         }
         $this->info("\n\nThese files will be published\n");
         $result = $this->confirm('Are you sure you want to overwrite any files of the same name?');
         if ($result) {
             $this->copyPreparedFiles(__DIR__ . '/../Packages/Semantic/', base_path());
             $this->info("\nYou will need to install semantic-ui:");
             $this->comment('npm install semantic-ui');
             $this->info("\nWhen prompted, select automatic detection.");
             $this->info("\nWhen prompted, select your project location, default should be fine.");
             $this->info("\nWhen prompted, set the directory to:");
             $this->comment('semantic');
             $this->info("\nThen run:");
             $this->comment('cd semantic && gulp build');
             $this->info("\nThen run:");
             $this->comment('cd ../ && gulp');
             $this->info("\nMake sure you set the PagesController@dashboard to use the following view:");
             $this->comment("'dashboard.main'");
             $this->info("\nFinished setting up semantic-ui in your app\n\n");
         } else {
             $this->info('You cancelled the laracogs semantic');
         }
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Filesystem $files)
 {
     $data = [];
     $newLocale = $this->input->getOption('locale');
     foreach (app('module.loader')->getRegisteredModules() as $module) {
         if (!is_dir($module->getLocalePath())) {
             continue;
         }
         foreach ($files->directories($module->getLocalePath()) as $localeDir) {
             $locale = basename($localeDir);
             if ($locale != $this->copiedLocale) {
                 continue;
             }
             foreach ($files->allFiles($localeDir) as $localeFile) {
                 $data[strtolower($module->getName())][] = $localeFile->getRealPath();
             }
         }
     }
     $langDirectory = base_path('/resources/lang/packages');
     foreach ($data as $namespace => $locales) {
         foreach ($locales as $group => $file) {
             $filename = pathinfo($file, PATHINFO_FILENAME);
             $fileDir = $langDirectory . DIRECTORY_SEPARATOR . $newLocale . DIRECTORY_SEPARATOR . $namespace;
             if (!$files->exists($fileDir)) {
                 $files->makeDirectory($fileDir, 0755, TRUE);
             }
             $files->copy($file, $fileDir . DIRECTORY_SEPARATOR . $filename . '.php');
         }
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Filesystem $files)
 {
     $langDirectory = base_path('resources' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR);
     $diff = [];
     foreach (ModulesLoader::getRegisteredModules() as $module) {
         if (!is_dir($module->getLocalePath()) or !$module->isPublishable()) {
             continue;
         }
         $locale = $this->input->getOption('locale');
         foreach ($files->directories($module->getLocalePath()) as $localeDir) {
             foreach ($files->allFiles($localeDir) as $localeFile) {
                 $vendorFileDir = $module->getKey() . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFile->getFilename();
                 $vendorFilePath = $langDirectory . $vendorFileDir;
                 if (file_exists($vendorFilePath)) {
                     $localArray = $files->getRequire($localeFile->getRealPath());
                     $vendorArray = $files->getRequire($vendorFilePath);
                     $array = array_keys_exists_recursive($localArray, $vendorArray);
                     $arrayDiff = '';
                     foreach (array_dot($array) as $key => $value) {
                         $arrayDiff .= "{$key}: {$value}\n";
                     }
                     if (empty($arrayDiff)) {
                         continue;
                     }
                     $diff[] = ['modules' . DIRECTORY_SEPARATOR . $vendorFileDir, 'vendor' . DIRECTORY_SEPARATOR . $vendorFileDir];
                     $diff[] = new TableSeparator();
                     $diff[] = [$arrayDiff, var_export(array_merge_recursive($array, $vendorArray), true)];
                     $diff[] = new TableSeparator();
                 }
             }
         }
     }
     $this->table($this->headers, $diff);
 }
 /**
  * @param   string       $directory directory name
  * @param   string|array $ext
  *
  * @return  array
  */
 public function listFiles($directory = null, $ext = null)
 {
     if ($directory !== null) {
         // Add the directory separator
         $directory .= DIRECTORY_SEPARATOR;
     }
     if ($ext === null) {
         // Use the default extension
         $ext = 'php';
     }
     $paths = $this->getPaths();
     // Create an array for the files
     $found = [];
     foreach ($paths as $moduleName => $path) {
         if (is_dir($path = normalize_path($path . DIRECTORY_SEPARATOR . $directory))) {
             foreach ($this->filesystem->allFiles($path) as $file) {
                 $fileExt = $file->getExtension();
                 // Relative filename is the array key
                 $key = $file->getRelativePathname();
                 if (!empty($ext) and is_array($ext) ? !in_array($fileExt, $ext) : $fileExt != $ext) {
                     continue;
                 }
                 if (!isset($found[$key])) {
                     $found[$key] = $file;
                 }
             }
         }
     }
     // Sort the results alphabetically
     ksort($found);
     return $found;
 }
 /**
  * Execute the console command.
  * @return void
  */
 public function fire()
 {
     $this->info('Initializing npm, bower and some boilerplates');
     // copiar templates
     $path_source = plugins_path('genius/elixir/assets/template/');
     $path_destination = base_path('/');
     $vars = ['{{theme}}' => Theme::getActiveTheme()->getDirName(), '{{project}}' => str_slug(BrandSettings::get('app_name'))];
     $fileSystem = new Filesystem();
     foreach ($fileSystem->allFiles($path_source) as $file) {
         if (!$fileSystem->isDirectory($path_destination . $file->getRelativePath())) {
             $fileSystem->makeDirectory($path_destination . $file->getRelativePath(), 0777, true);
         }
         $fileSystem->put($path_destination . $file->getRelativePathname(), str_replace(array_keys($vars), array_values($vars), $fileSystem->get($path_source . $file->getRelativePathname())));
     }
     $this->info('... initial setup is ok!');
     $this->info('Installing npm... this can take several minutes!');
     // instalar NPM
     system("cd '{$path_destination}' && npm install");
     $this->info('... node components is ok!');
     $this->info('Installing bower... this will no longer take as!');
     // instalar NPM
     system("cd '{$path_destination}' && bower install");
     $this->info('... bower components is ok!');
     $this->info('Now... edit the /gulpfile.js as you wish and edit your assets at/ resources directory... that\'s is!');
 }
Example #18
0
 /**
  * Generate defined module folders.
  */
 protected function generateModule()
 {
     if (!$this->files->isDirectory(module_path())) {
         $this->files->makeDirectory(module_path());
     }
     $pathMap = config('modules.pathMap');
     $directory = module_path(null, $this->container['basename']);
     $source = __DIR__ . '/../../../resources/stubs/module';
     $this->files->makeDirectory($directory);
     $sourceFiles = $this->files->allFiles($source, true);
     if (!empty($pathMap)) {
         $search = array_keys($pathMap);
         $replace = array_values($pathMap);
     }
     foreach ($sourceFiles as $file) {
         $contents = $this->replacePlaceholders($file->getContents());
         $subPath = $file->getRelativePathname();
         if (!empty($pathMap)) {
             $subPath = str_replace($search, $replace, $subPath);
         }
         $filePath = $directory . '/' . $subPath;
         $dir = dirname($filePath);
         if (!$this->files->isDirectory($dir)) {
             $this->files->makeDirectory($dir, 0755, true);
         }
         $this->files->put($filePath, $contents);
     }
 }
Example #19
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $name = $this->argument('name');
     $fileSystem = new Filesystem();
     $files = $fileSystem->allFiles(base_path('resources/themes/' . strtolower($name) . '/public'));
     foreach ($files as $file) {
         if ($file->getType() === 'file') {
             $this->line(public_path($file->getBasename()));
         }
     }
     $this->info("\n\nThese files will be overwritten\n");
     if (!$this->option('forced')) {
         $result = $this->confirm('Are you sure you want to overwrite any files of the same name?');
     } else {
         $result = true;
     }
     if ($result) {
         foreach ($files as $file) {
             $newFileName = str_replace(base_path('resources/themes/' . strtolower($name) . '/public/'), '', $file);
             $this->line('Copying ' . public_path($newFileName) . '...');
             if (is_dir($file)) {
                 $fileSystem->copyDirectory($file, public_path($newFileName));
             } else {
                 @mkdir(public_path(str_replace(basename($newFileName), '', $newFileName)), 0755, true);
                 $fileSystem->copy($file, public_path($newFileName));
             }
         }
     } else {
         $this->info("\n\nNo files were published\n");
     }
 }
 /**
  * Execute the command.
  *
  * @param Filesystem $fileSystem
  * @param Application $app
  * @param TranslationRepositoryInterface $repository
  * @param Dispatcher $event
  * @return Collection of Group
  */
 public function handle(Filesystem $fileSystem, Application $app, TranslationRepositoryInterface $repository, Dispatcher $event)
 {
     $files = $fileSystem->allFiles($app->langPath());
     /**
      * Retrieves all local languages
      */
     $languages = collect($files)->transform(function ($file) {
         return $file->getRelativePath();
     })->unique();
     /**
      * Save Database instance with all languages
      */
     $database = $repository->languages();
     /**
      * List Only names
      */
     $names = $database->pluck('name');
     /**
      * Create New Language for those which has been set locally
      * but was not present yet on the database
      */
     $newLanguages = $languages->merge($names)->diff($names)->map(function ($name) {
         return $this->dispatch(new CreateLanguageCommand($name));
     });
     /**
      * Announce LanguagesWasCreated
      */
     if (!$newLanguages->isEmpty()) {
         $event->fire(new LanguagesWasCreated($newLanguages));
     }
     /**
      * Returns All languages
      */
     return $database->merge($newLanguages);
 }
Example #21
0
 public static function emailTemplates()
 {
     $path = Config::get('view.paths');
     $fileSystem = new Filesystem();
     $files = $fileSystem->allFiles($path[0] . DIRECTORY_SEPARATOR . Theme::getTheme() . DIRECTORY_SEPARATOR . "emails");
     return $files;
 }
Example #22
0
 public static function widgets()
 {
     $path = Config::get('view.paths');
     $fileSystem = new Filesystem();
     $theme = Theme::getTheme();
     $files = $fileSystem->allFiles($path[0] . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR . "widgets");
     return $files;
 }
Example #23
0
 private function getTemplates()
 {
     $path = $this->getCurrentThemeBasePath();
     $templates = [];
     foreach ($this->finder->allFiles($path . '/views') as $template) {
         $relativePath = $template->getRelativePath();
         if ($this->isLayoutOrPartial($relativePath)) {
             continue;
         }
         $file = $this->removeExtensionsFromFilename($template);
         if ($this->hasSubdirectory($relativePath)) {
             $templates[$relativePath . '.' . $file] = $relativePath . '/' . $file;
         } else {
             $templates[$file] = $file;
         }
     }
     return $templates;
 }
Example #24
0
 /**
  * Load the locale translation files.
  *
  * @param  string  $path
  *
  * @return array
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 private function loadLocaleFiles($path)
 {
     $files = [];
     foreach ($this->filesystem->allFiles($path) as $file) {
         /** @var \Symfony\Component\Finder\SplFileInfo $file */
         $key = str_replace(['.php', DS], ['', '.'], $file->getRelativePathname());
         $files[$key] = ['path' => $file->getRealPath(), 'content' => $this->filesystem->getRequire($file)];
     }
     return $files;
 }
 /**
  * Get Original Imported FileName
  *
  * @param $key
  * @return string|null
  */
 protected function getOriginalFileName($key)
 {
     $files = $this->filesystem->allFiles($this->getFilePath($key));
     foreach ($files as $file) {
         if (!in_array(pathinfo($file, PATHINFO_EXTENSION), ['pdf', 'json'])) {
             return ['name' => $file->getRelativePathname(), 'created_at' => filemtime($file)];
         }
     }
     return null;
 }
Example #26
0
 /**
  * Handle the options.
  *
  * @param SelectFieldType $fieldType
  * @param ThemeCollection $themes
  * @param Repository      $config
  * @param Filesystem      $files
  */
 public function handle(SelectFieldType $fieldType, ThemeCollection $themes, Repository $config, Filesystem $files)
 {
     $theme = $themes->get($config->get('streams::themes.standard'));
     $options = $files->allFiles($theme->getPath('resources/views/layouts'));
     $fieldType->setOptions(array_combine(array_map(function ($path) use($theme) {
         return 'theme::' . ltrim(str_replace($theme->getPath('resources/views'), '', $path), '/');
     }, $options), array_map(function ($path) use($theme) {
         return ltrim(str_replace($theme->getPath('resources/views/layouts'), '', $path), '/');
     }, $options)));
 }
 /**
  * @return array
  */
 public function getVendorNames()
 {
     $files = new Filesystem();
     $vendor_directories = $files->allFiles($this->getBaseDirectory());
     $vendor_directory_names = array();
     foreach ($vendor_directories as $vendor_directory) {
         $name = strtolower($vendor_directory->getBasename($this->getVendorFileTypeSuffix()));
         $vendor_directory_names[$name] = $vendor_directory->getRelativePathname();
     }
     return $vendor_directory_names;
 }
 function it_should_read_the_directory_if_one_was_provided(Application $app, Filesystem $files)
 {
     $path = './my-path';
     $allFiles = ['./my-path/file1.php', './my-path/file2.php'];
     $files->exists($path)->willReturn(true);
     $files->isDirectory($path)->willReturn(true);
     $files->allFiles($path)->willReturn($allFiles)->shouldBeCalled();
     $app->make('files')->willReturn($files);
     $this->filesToPublish($path);
     $this->files()->shouldReturn($allFiles);
 }
 /**
  * @param Filesystem $files
  * @param            $path
  * @param            $namespace
  *
  * @return array
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 protected function loadLangFromPath(Filesystem $files, $path, $namespace)
 {
     $data = [];
     foreach ($files->directories($path) as $localeDir) {
         $locale = basename($localeDir);
         foreach ($files->allFiles($localeDir) as $localeFile) {
             $data[$locale][$namespace][basename($localeFile, '.php')] = $files->getRequire($localeFile->getRealPath());
         }
     }
     return $data;
 }
Example #30
0
 private function __construct()
 {
     $this->_http = new Http();
     // Инициализация конфигов
     $fileSystem = new Filesystem();
     $files = $fileSystem->allFiles('config');
     foreach ($files as $file) {
         if (is_array($fileSystem->getRequire($file))) {
             $this->setConfig($fileSystem->getRequire($file), $fileSystem->name($file));
         }
     }
 }