本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::allfiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::allfiles方法的具体用法?PHP Filesystem::allfiles怎么用?PHP Filesystem::allfiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::allfiles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importTranslations
public function importTranslations()
{
$counter = 0;
foreach ($this->files->directories($this->app->langPath()) as $langPath) {
$locale = basename($langPath);
foreach ($this->files->allfiles($langPath) as $file) {
$info = pathinfo($file);
$group = $info['filename'];
if (in_array($group, $this->config['exclude_groups'])) {
continue;
}
if ($langPath != $info['dirname']) {
$group = substr(str_replace($langPath, '', $info['dirname']) . '/' . $info['filename'], 1);
}
$g = Group::firstOrNew(array('label' => $group));
$g->save();
$l = Locale::firstOrNew(array('label' => $locale));
$l->save();
$translations = \Lang::getLoader()->load($locale, $group);
if ($translations && is_array($translations)) {
foreach (array_dot($translations) as $key => $value) {
// process only string values
if (is_array($value)) {
continue;
}
$value = (string) $value;
$translation = Translation::firstOrNew(['locale_id' => $l->id, 'key' => $key]);
$g->translations()->save($translation);
// 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;
}
$translation->value = $value;
$translation->save();
$counter++;
}
}
}
}
return $counter;
}
示例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) {
$info = pathinfo($file);
$group = $info['filename'];
if (in_array($group, $this->config['exclude_groups'])) {
continue;
}
$subLangPath = str_replace($langPath . DIRECTORY_SEPARATOR, "", $info['dirname']);
if ($subLangPath != $langPath) {
$group = $subLangPath . "/" . $group;
}
$translations = \Lang::getLoader()->load($locale, $group);
if ($translations && is_array($translations)) {
foreach (array_dot($translations) as $key => $value) {
// process only string values
if (is_array($value)) {
continue;
}
$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;
}