本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: basename
function available_languages()
{
$langs = $this->filesystem->directories($this->storage_path);
$langs = array_map(function ($l) {
return basename($l);
}, $langs);
return $langs;
}
示例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');
}
}
}
示例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 ?: [];
}
示例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);
}
示例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;
}, []);
}
示例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;
}
示例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;
}
示例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());
}
}
示例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;
}
示例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);
}
}
示例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;
}, []);
}