當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Filesystem::allfiles方法代碼示例

本文整理匯總了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;
 }
開發者ID:camdjn,項目名稱:laravel-translation-manager,代碼行數:42,代碼來源:Manager.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) {
             $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;
 }
開發者ID:barryvdh,項目名稱:laravel-translation-manager,代碼行數:41,代碼來源:Manager.php


注:本文中的Illuminate\Filesystem\Filesystem::allfiles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。