summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2022-03-06 01:07:59 +0100
committerDaniel Weipert <code@drogueronin.de>2022-03-06 01:07:59 +0100
commitad83d1dafac62bb28fda004f86129319a5c3e2ca (patch)
treedcf119ae4159dcd13c5c3651e54b92e3f7cd4f80 /src
parentb2a86c7df7d5a473e80034832a01b21444fa50e6 (diff)
Refactor fixes
Diffstat (limited to 'src')
-rw-r--r--src/App.php7
-rw-r--r--src/Controllers/EntriesController.php4
-rw-r--r--src/Controllers/SubmissionController.php2
-rw-r--r--src/HookManager.php4
-rw-r--r--src/PluginLoader.php2
5 files changed, 12 insertions, 7 deletions
diff --git a/src/App.php b/src/App.php
index 15be58b..5fc62fa 100644
--- a/src/App.php
+++ b/src/App.php
@@ -20,6 +20,11 @@ class App
*/
public function __construct()
{
+ /**@var HookManager $hooks*/
+ global $hooks;
+
+ $hooks->doAction('init');
+
$request = Request::createFromGlobals();
$response = new Response();
@@ -64,7 +69,7 @@ class App
$entriesController = new EntriesController();
- $content = $entriesController->getEntries();
+ $content = $entriesController->getEntries($formPath);
}
else {
diff --git a/src/Controllers/EntriesController.php b/src/Controllers/EntriesController.php
index 13aa8e0..801fe7b 100644
--- a/src/Controllers/EntriesController.php
+++ b/src/Controllers/EntriesController.php
@@ -6,7 +6,7 @@ use Yosymfony\Toml\Toml;
class EntriesController
{
- public function getEntries()
+ public function getEntries(string $formPath): array
{
/**@var Utilities $utilities*/
global $utilities;
@@ -65,7 +65,7 @@ class EntriesController
$entriesForDay = $utilities->scandir($dayPath);
foreach ($entriesForDay as $entryForDay) {
- $entry = Toml::parseFile("$dayPath/$entryForDay");
+ $entry = Toml::parseFile($entryForDay);
if (isset($_GET['flat'])) {
$entries[] = $entry;
} else {
diff --git a/src/Controllers/SubmissionController.php b/src/Controllers/SubmissionController.php
index f2c4c80..2c3d603 100644
--- a/src/Controllers/SubmissionController.php
+++ b/src/Controllers/SubmissionController.php
@@ -8,7 +8,7 @@ use Yosymfony\Toml\TomlBuilder;
class SubmissionController
{
- public function submit(Builder $builder, Validator $validator, $formPath)
+ public function submit(Builder $builder, Validator $validator, string $formPath): array
{
$fields = $builder->buildFields();
diff --git a/src/HookManager.php b/src/HookManager.php
index 96ca8d3..0f252c8 100644
--- a/src/HookManager.php
+++ b/src/HookManager.php
@@ -9,12 +9,12 @@ class HookManager
public function addAction(string $name, callable $function, int $priority = 10): void
{
- $this->action[$name][$priority][] = compact('name', 'function', 'priority');
+ $this->actions[$name][$priority][] = compact('name', 'function', 'priority');
}
public function addFilter(string $name, callable $function, int $priority = 10): void
{
- $this->filters[$name][$priority][] = compact('name', 'callable', 'priority');
+ $this->filters[$name][$priority][] = compact('name', 'function', 'priority');
}
public function doAction(string $name, mixed ...$arguments): void
diff --git a/src/PluginLoader.php b/src/PluginLoader.php
index c8da5fd..b2ac61d 100644
--- a/src/PluginLoader.php
+++ b/src/PluginLoader.php
@@ -22,7 +22,7 @@ class PluginLoader
$pluginDirectories = $utilities->scandir($pluginsDirectoryPath);
foreach ($pluginDirectories as $directory) {
- $pluginClass = 'FlatFileForms\\Plugins\\' . $directory . '\\Plugin';
+ $pluginClass = 'FlatFileForms\\Plugins\\' . basename($directory) . '\\Plugin';
$plugin = new $pluginClass();
}
}