PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 3.6.42
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v3.6.42
6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 3.6.66 All 195 releases
fluentform / framework / Config / ConfigProvider.php

ConfigProvider.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 3.6.42, at framework/Config/ConfigProvider.php

70 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\Framework\Config;
4
5 use RecursiveIteratorIterator;
6 use RecursiveDirectoryIterator;
7 use FluentForm\Framework\Foundation\Provider;
8
9 class ConfigProvider extends Provider
10 {
11 /**
12 * The provider booting method to boot this provider
13 * @return void
14 */
15 public function booting()
16 {
17 $config = new Config(array('app' => $this->app->getAppConfig()));
18
19 $this->app->bindInstance(
20 'config', $config, 'Config', 'FluentForm\Framework\Config\Config'
21 );
22 }
23
24 /**
25 * The provider booted method to be called after booting
26 * @return void
27 */
28 public function booted()
29 {
30 $this->loadConfig();
31 }
32
33 /**
34 * Loads all configuration files from config directory
35 * @return void
36 */
37 public function loadConfig()
38 {
39 $files = [];
40 $configPath = $this->app->configPath();
41 $itr = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(
42 $configPath, RecursiveDirectoryIterator::SKIP_DOTS
43 ));
44
45 foreach($itr as $file) {
46 if (pathinfo($file, PATHINFO_EXTENSION) == "php" && $file->getFileName() != 'app.php') {
47 $fileRealPath = $file->getRealPath();
48 $directory = $this->getDirectory($file, $configPath);
49 $this->app->config->set($directory.basename($fileRealPath, '.php'), include $fileRealPath);
50 }
51 }
52 }
53
54 /**
55 * Get nested directory names joined by a "."
56 * @param string $file [A config file]
57 * @param string $configPath
58 * @return string
59 */
60 protected function getDirectory($file, $configPath)
61 {
62 $ds = DIRECTORY_SEPARATOR;
63
64 if ($directory = trim(str_replace(trim($configPath, '/'), '', $file->getPath()), $ds)) {
65 $directory = str_replace($ds, '.', $directory).'.';
66 }
67
68 return $directory;
69 }
70 }