本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::allFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::allFiles方法的具体用法?PHP Filesystem::allFiles怎么用?PHP Filesystem::allFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::allFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: stepDirectories
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);
}
}
示例3: it_generates_correct_default_migration_file_content
/** @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);
}
示例4: getFiles
/**
* 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;
}
示例5: getAllFiles
public function getAllFiles($languageCode)
{
$files = $this->filesystem->allFiles(app_path() . '/lang/' . $languageCode . '/borrower/');
$filePaths = [];
foreach ($files as $file) {
$filePaths[] = $file->getRelativePathname();
}
return $filePaths;
}
示例6: addNamespaceOverrides
/**
* 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())));
}
}
示例7: fire
/**
* 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;
}
示例8: all
/**
* 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;
}
示例9: search
/**
* 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;
}
示例10: handle
/**
* 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');
}
}
}
示例11: run
/**
* 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]);
}
}
示例12: templates
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;
}
示例13: handle
/**
* 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');
}
}
}
示例14: fire
/**
* 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');
}
}
}
示例15: fire
/**
* 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);
}