Skip to content

Commit 7efc61c

Browse files
authored
Merge pull request #2 from Neuron-PHP/feature/variable-filters
Feature/variable filters
2 parents 1066d4d + 96cb53a commit 7efc61c

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

.version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"strategy": "semver",
33
"major": 0,
44
"minor": 8,
5-
"patch": 12,
5+
"patch": 13,
66
"build": 0
77
}

src/Mvc/Controllers/Base.php

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace Neuron\Mvc\Controllers;
44

55
use League\CommonMark\Exception\CommonMarkException;
6-
use Neuron\Application\IApplication;
76
use Neuron\Core\Exceptions\BadRequestMethod;
7+
use Neuron\Data\Filter\Get;
8+
use Neuron\Data\Filter\Post;
89
use Neuron\Data\Setting\SettingManager;
9-
use Neuron\Data\Setting\Source\ISettingSource;
1010
use Neuron\Mvc\Application;
1111
use Neuron\Mvc\Cache\CacheConfig;
1212
use Neuron\Mvc\Cache\Exceptions\CacheException;
@@ -884,4 +884,46 @@ public function __call( string $method, array $arguments ): ?string
884884
// If no URL helper pattern matches, throw an exception
885885
throw new \BadMethodCallException( "Method '$method' not found in " . static::class );
886886
}
887+
888+
/**
889+
* Filter and retrieve a GET parameter.
890+
*
891+
* @param string $paramName The name of the GET parameter
892+
* @param mixed $default The default value if parameter is not present
893+
* @return mixed The filtered GET parameter value or default
894+
*/
895+
public function filterGet( string $paramName, mixed $default = null ) : mixed
896+
{
897+
$get = new Get();
898+
899+
return $get->filterScalar( $paramName ) ?? $default;
900+
}
901+
902+
/**
903+
* Filter and retrieve a POST parameter.
904+
*
905+
* @param string $paramName The name of the POST parameter
906+
* @param mixed $default The default value if parameter is not present
907+
* @return mixed The filtered POST parameter value or default
908+
*/
909+
public function filterPost( string $paramName, mixed $default = null ) : mixed
910+
{
911+
$post = new Post();
912+
913+
return $post->filterScalar( $paramName ) ?? $default;
914+
}
915+
916+
/**
917+
* Filter and retrieve a SERVER parameter.
918+
*
919+
* @param string $paramName The name of the SERVER parameter
920+
* @param mixed $default The default value if parameter is not present
921+
* @return mixed The filtered SERVER parameter value or default
922+
*/
923+
public function filterServer( string $paramName, mixed $default = null ): mixed
924+
{
925+
$server = new \Neuron\Data\Filter\Server();
926+
927+
return $server->filterScalar( $paramName ) ?? $default;
928+
}
887929
}

versionlog.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
## 0.8.13
2+
13
## 0.8.12 2025-11-12
2-
* Added ViewDataProvider interface for injecting data into views globally.
4+
* Added ViewDataProvider for global view data injection
5+
- Eliminates need for views to call Registry::getInstance()
6+
- Supports both static values and lazy-evaluated callables
7+
- Automatic injection into all views via Base::injectHelpers()
8+
- Fluent API for configuration in initializers
9+
- Comprehensive PHPUnit test coverage (19 tests)
10+
- Template ViewDataInitializer in resources/app/Initializers/
11+
- Full documentation in readme.md
312

413
## 0.8.11 2025-11-12
514
* Renamed config.yaml to neuron.yaml

0 commit comments

Comments
 (0)