summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/index.php2
-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
6 files changed, 13 insertions, 8 deletions
diff --git a/public/index.php b/public/index.php
index 8a7ec7d..96332f7 100644
--- a/public/index.php
+++ b/public/index.php
@@ -29,7 +29,7 @@ function findAppConfigFile(string $path): string
$configFile = findAppConfigFile(dirname(__DIR__));
$config = Toml::parseFile($configFile);
-// prepare possibly relative folders path
+// prepare possibly relative folder paths
chdir(dirname($configFile));
$contentDirectoryPath = realpath($config['app']['contentFolderPath']);
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();
}
}