当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::directories方法代码示例

本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::directories方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::directories方法的具体用法?PHP Filesystem::directories怎么用?PHP Filesystem::directories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Filesystem\Filesystem的用法示例。


在下文中一共展示了Filesystem::directories方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getExtensions

 /**
  * 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;
 }
开发者ID:notadd,项目名称:framework,代码行数:34,代码来源:ExtensionManager.php

示例2: importTranslations

 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;
 }
开发者ID:kitbs,项目名称:laravel-translation-manager,代码行数:33,代码来源:Manager.php

示例3: importTranslations

 public function importTranslations($replace = false)
 {
     $counter = 0;
     foreach ($this->files->directories($this->app->make('path') . '/lang') as $langPath) {
         $locale = basename($langPath);
         foreach ($this->files->files($langPath) as $file) {
             $info = pathinfo($file);
             $group = $info['filename'];
             if (in_array($group, $this->config['exclude_groups'])) {
                 continue;
             }
             $translations = array_dot(\Lang::getLoader()->load($locale, $group));
             foreach ($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;
 }
开发者ID:antonioribeiro,项目名称:laravel-translation-manager,代码行数:31,代码来源:Manager.php

示例4: getModules

 /**
  * 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;
 }
开发者ID:notadd,项目名称:framework,代码行数:34,代码来源:ModuleManager.php

示例5: basename

 function available_languages()
 {
     $langs = $this->filesystem->directories($this->storage_path);
     $langs = array_map(function ($l) {
         return basename($l);
     }, $langs);
     return $langs;
 }
开发者ID:avvertix,项目名称:pronto-framework,代码行数:8,代码来源:Content.php

示例6: handle

 /**
  * Handle the command.
  *
  * @param ClassMapGenerator $generator
  * @param Filesystem $files
  */
 public function handle(ClassMapGenerator $generator, Filesystem $files)
 {
     foreach ($files->directories(base_path('storage/streams')) as $directory) {
         if (is_dir($models = $directory . '/models')) {
             $generator->dump($files->directories($models), $models . '/classmap.php');
         }
     }
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:14,代码来源:GenerateEntryModelClassmap.php

示例7: findInstalledThemes

 public function findInstalledThemes()
 {
     $theme = new Theme();
     $themes = $this->filesystem->directories($theme->getThemesDirectory());
     if (is_array($themes)) {
         foreach ($themes as &$t) {
             $t = new Theme(str_replace($theme->getThemesDirectory() . '/', '', $t));
         }
     }
     return $themes ?: [];
 }
开发者ID:imanghafoori1,项目名称:boom-core,代码行数:11,代码来源:Manager.php

示例8: all

 /**
  * Get all themes.
  *
  * @return Collection
  */
 public function all()
 {
     $themes = [];
     if ($this->files->exists($this->getPath())) {
         $scannedThemes = $this->files->directories($this->getPath());
         foreach ($scannedThemes as $theme) {
             $themes[] = basename($theme);
         }
     }
     return new Collection($themes);
 }
开发者ID:hilabs,项目名称:Theme,代码行数:16,代码来源:Theme.php

示例9: findThemes

 /**
  * @return mixed
  */
 private function findThemes()
 {
     $directories = $this->filesystem->directories($this->config->get('themes.path'));
     return Collection::make($directories)->reduce(function (&$initial, $directory) {
         $plugin = $this->get_theme_date($directory . '/style.css');
         if (!empty($plugin['Name']) && !empty($plugin['Version'])) {
             $plugin['Name'] = basename($directory);
             $initial[] = $this->transformWPPluginToTheme($plugin);
         }
         return $initial;
     }, []);
 }
开发者ID:Zae,项目名称:wp-vulnerabilities,代码行数:15,代码来源:Files.php

示例10: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $countries = $this->files->directories($this->path);
     $cities = [];
     foreach ($countries as $countryDirectory) {
         $states = $this->files->files($countryDirectory);
         $country = $this->last(explode(DIRECTORY_SEPARATOR, $countryDirectory));
         foreach ($states as $stateDirectory) {
             list($state, $_) = explode('.', $this->last(explode(DIRECTORY_SEPARATOR, $stateDirectory)));
             $data = $this->loader->load($country, $state, 'en');
             foreach ($data as $key => $name) {
                 $cities[] = ['name' => $name, 'code' => "{$country} {$state} {$key}", 'state_id' => "{$country} {$state}"];
             }
         }
     }
     $cities = Collection::make($cities);
     $hash = md5($cities->toJson());
     if (!$this->option('force') && $hash === $this->hash) {
         $this->line('No new city.');
         return false;
     }
     $cityCodes = $cities->pluck('code');
     $stateCodes = $cities->pluck('state_id')->unique();
     $stateIds = Collection::make(DB::table($this->states)->whereIn('code', $stateCodes)->pluck('id', 'code'));
     $cities = $cities->map(function ($item) use($stateIds) {
         $item['state_id'] = $stateIds->get($item['state_id']);
         return $item;
     });
     $existingCityIDs = Collection::make(DB::table($this->cities)->whereIn('code', $cityCodes)->pluck('id', 'code'));
     $cities = $cities->map(function ($item) use($existingCityIDs) {
         if ($existingCityIDs->has($item['code'])) {
             $item['id'] = $existingCityIDs->get($item['code']);
         }
         return $item;
     });
     $cities = $cities->groupBy(function ($item) {
         return array_has($item, 'id') ? 'update' : 'create';
     });
     DB::transaction(function () use($cities, $hash) {
         $create = Collection::make($cities->get('create'));
         $update = Collection::make($cities->get('update'));
         foreach ($create->chunk(static::QUERY_LIMIT) as $entries) {
             DB::table($this->cities)->insert($entries->toArray());
         }
         foreach ($update as $entries) {
             DB::table($this->cities)->where('id', $entries['id'])->update($entries);
         }
         $this->line("{$create->count()} cities created. {$update->count()} cities updated.");
         $this->files->put(storage_path(static::INSTALL_HISTORY), $hash);
     });
     return true;
 }
开发者ID:znck,项目名称:cities,代码行数:57,代码来源:UpdateCitiesCommand.php

示例11: all

 /**
  * Get all themes
  */
 public function all()
 {
     $themes = array();
     if (!$this->filesystem->isDirectory($path = $this->themesPath)) {
         return array();
     }
     $directories = $this->filesystem->directories($path);
     foreach ($directories as $theme) {
         $themeName = basename($theme);
         $themes[$themeName] = $this->getThemeInfo($themeName);
     }
     return $themes;
 }
开发者ID:ionutmilica,项目名称:themes,代码行数:16,代码来源:ThemeFinder.php

示例12: getAllBasenames

 /**
  * Get all module basenames
  *
  * @return array
  */
 protected function getAllBasenames()
 {
     $path = $this->getPath();
     try {
         $collection = collect($this->files->directories($path));
         $basenames = $collection->map(function ($item, $key) {
             return basename($item);
         });
         return $basenames;
     } catch (\InvalidArgumentException $e) {
         return collect(array());
     }
 }
开发者ID:mubassirhayat,项目名称:modules,代码行数:18,代码来源:Repository.php

示例13: findAndInstallThemes

 /**
  * Create a cache of the themes which are available on the filesystem.
  *
  * @return array
  */
 public function findAndInstallThemes()
 {
     $theme = new Theme();
     $directories = $this->filesystem->directories($theme->getThemesDirectory());
     $themes = [];
     if (is_array($directories)) {
         foreach ($directories as $directory) {
             $themeName = basename($directory);
             $themes[] = new Theme($themeName);
         }
     }
     $this->cache->forever($this->cacheKey, $themes);
     return $themes;
 }
开发者ID:boomcms,项目名称:boom-core,代码行数:19,代码来源:Manager.php

示例14: loadExtensions

 /**
  * Load extensions in memory
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function loadExtensions()
 {
     $extensions = $this->filesystem->directories($this->path);
     foreach ($extensions as $extension) {
         $name = basename($extension);
         $class = $this->extensionClass($name);
         $this->filesystem->getRequire($extension . '/start.php');
         $extensionInstance = new $class($extension, $name);
         if (in_array($name, $this->settings->get('extensions', []))) {
             $extensionInstance->setActive();
         }
         $this->extensions->push($extensionInstance);
     }
 }
开发者ID:vjaykoogu,项目名称:smile-media-laravel,代码行数:19,代码来源:Manager.php

示例15: findPlugins

 /**
  * @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;
     }, []);
 }
开发者ID:Zae,项目名称:wp-vulnerabilities,代码行数:18,代码来源:Files.php


注:本文中的Illuminate\Filesystem\Filesystem::directories方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。