diff options
author | Daniel Weipert <code@drogueronin.de> | 2022-03-06 11:45:31 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2022-03-06 11:45:31 +0100 |
commit | 1334236bb6059b2302a760196ce7885df379e984 (patch) | |
tree | f86e883e6ae9510454307f38be3ffd20aefa6c4c /src/App.php | |
parent | ad83d1dafac62bb28fda004f86129319a5c3e2ca (diff) |
toml to yaml
Diffstat (limited to 'src/App.php')
-rw-r--r-- | src/App.php | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/App.php b/src/App.php index 5fc62fa..ea9aa29 100644 --- a/src/App.php +++ b/src/App.php @@ -8,8 +8,7 @@ use FlatFileForms\Controllers\SubmissionController; use FlatFileForms\Controllers\ValidationController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Yosymfony\Toml\Toml; -use Yosymfony\Toml\TomlBuilder; +use Symfony\Component\Yaml\Yaml; class App { @@ -23,8 +22,13 @@ class App /**@var HookManager $hooks*/ global $hooks; + /**@var Form $form*/ + global $form; + $hooks->doAction('init'); + global $request; + global $response; $request = Request::createFromGlobals(); $response = new Response(); @@ -36,6 +40,7 @@ class App $method = $request->getMethod(); $path = $request->getPathInfo(); + $config = []; try { $config = $this->buildConfig($contentRoot . $path); @@ -52,6 +57,7 @@ class App if ($method == 'GET') { if (str_ends_with($path, '/fields')) { $formPath = $contentRoot . str_replace('/fields', '', $path); + $form = new Form($formPath); $builder = new Builder($formPath); @@ -66,6 +72,7 @@ class App } $formPath = $contentRoot . str_replace('/entries', '', $path); + $form = new Form($formPath); $entriesController = new EntriesController(); @@ -73,7 +80,7 @@ class App } else { - $content['data'] = Toml::parseFile($contentRoot . $path . '.toml'); + $content['data'] = Yaml::parseFile($contentRoot . $path . '.yaml'); } } @@ -81,6 +88,7 @@ class App else if ($method == 'POST') { if (str_ends_with($path, '/validate')) { $formPath = $contentRoot . str_replace('/validate', '', $path); + $form = new Form($formPath); $builder = new Builder($formPath); $validator = new Validator($formPath); @@ -92,6 +100,7 @@ class App else if (str_ends_with($path, '/submit')) { $formPath = $contentRoot . str_replace('/submit', '', $path); + $form = new Form($formPath); $builder = new Builder($formPath); $validator = new Validator($formPath); @@ -124,9 +133,9 @@ class App $config = []; $currentDirectory = $requestPath; while (true) { - $configFile = $currentDirectory . '/config/config.toml'; + $configFile = $currentDirectory . '/config/config.yaml'; if (file_exists($configFile)) { - $parsedConfig = Toml::parseFile($configFile); + $parsedConfig = Yaml::parseFile($configFile); $apiKeys = array_merge($parsedConfig['api']['keys'] ?? [], $config['api']['keys'] ?? []); $config = array_replace_recursive($parsedConfig, $config); |