Skip to content

Commit a7c71b4

Browse files
committed
Merge branch 'release/0.9.46'
2 parents 923a43c + dcc8636 commit a7c71b4

25 files changed

Lines changed: 177 additions & 152 deletions

.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": 9,
5-
"patch": 45,
5+
"patch": 46,
66
"build": 0
77
}

src/Bootstrap.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Neuron\Mvc;
33

44
use Neuron\Core\Exceptions\NotFound;
5+
use Neuron\Core\Registry\RegistryKeys;
56
use Neuron\Core\System\IFileSystem;
67
use Neuron\Core\System\RealFileSystem;
78
use Neuron\Data\Filters\Get;
@@ -112,7 +113,7 @@ function dispatch( Application $app ) : void
112113
{
113114
// Check if this exception should pass through to caller (e.g., public/index.php)
114115
// Applications can configure exception classes via neuron.yaml under 'exceptions.passthrough'
115-
$passthroughExceptions = Registry::getInstance()->get( 'PassthroughExceptions' ) ?? [];
116+
$passthroughExceptions = Registry::getInstance()->get( RegistryKeys::PASSTHROUGH_EXCEPTIONS_LEGACY ) ?? [];
116117
$exceptionClass = get_class( $e );
117118

118119
\Neuron\Log\Log::debug( 'Exception caught: ' . $exceptionClass );
@@ -156,11 +157,11 @@ function partial( string $name, array $data = [], ?IFileSystem $fs = null ) : vo
156157
$fs = $fs ?? new RealFileSystem();
157158

158159
$path = Registry::getInstance()
159-
->get( "Views.Path" );
160+
->get( RegistryKeys::VIEWS_PATH );
160161

161162
if( !$path )
162163
{
163-
$basePath = Registry::getInstance()->get( "Base.Path" );
164+
$basePath = Registry::getInstance()->get( RegistryKeys::BASE_PATH );
164165
$path = "$basePath/resources/views";
165166
}
166167

src/Mvc/Application.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Neuron\Core\Exceptions\NotFound;
1111
use Neuron\Core\Exceptions\Unauthorized;
1212
use Neuron\Core\Exceptions\Validation;
13+
use Neuron\Core\Registry\RegistryKeys;
1314
use Neuron\Core\System\IFileSystem;
1415
use Neuron\Core\System\RealFileSystem;
1516
use Neuron\Data\Settings\Source\ISettingSource;
@@ -62,18 +63,18 @@ public function __construct( string $version ="1.0.0", ?ISettingSource $source =
6263
$passthroughExceptions = $this->getSetting( 'exceptions', 'passthrough' );
6364
if( is_array( $passthroughExceptions ) )
6465
{
65-
Registry::getInstance()->set( 'PassthroughExceptions', $passthroughExceptions );
66+
Registry::getInstance()->set( RegistryKeys::PASSTHROUGH_EXCEPTIONS_LEGACY, $passthroughExceptions );
6667
\Neuron\Log\Log::debug( 'Loaded passthrough exceptions: ' . json_encode( $passthroughExceptions ) );
6768
}
6869
else
6970
{
7071
// No exceptions configured, set to empty array
71-
Registry::getInstance()->set( 'PassthroughExceptions', [] );
72+
Registry::getInstance()->set( RegistryKeys::PASSTHROUGH_EXCEPTIONS_LEGACY, [] );
7273
\Neuron\Log\Log::debug( 'No passthrough exceptions configured' );
7374
}
7475

75-
Registry::getInstance()->set( 'BasePath', $this->getBasePath() );
76-
Registry::getInstance()->set( 'App', $this );
76+
Registry::getInstance()->set( RegistryKeys::BASE_PATH_LEGACY, $this->getBasePath() );
77+
Registry::getInstance()->set( RegistryKeys::APP, $this );
7778

7879
$this->loadRequests();
7980
$this->loadRoutes();
@@ -113,9 +114,9 @@ protected function loadRequests(): void
113114
{
114115
$requestPath = $this->getBasePath().'/config/requests';
115116

116-
if( $this->getRegistryObject( 'Requests.Path' ) )
117+
if( $this->getRegistryObject( RegistryKeys::REQUESTS_PATH ) )
117118
{
118-
$requestPath = $this->getRegistryObject( 'Requests.Path' );
119+
$requestPath = $this->getRegistryObject( RegistryKeys::REQUESTS_PATH );
119120
}
120121

121122
$files = $this->fs->glob($requestPath . '/*.yaml');
@@ -227,7 +228,7 @@ protected function onStart(): bool
227228
$basePath = $this->getBasePath();
228229

229230
if( $viewPath )
230-
Registry::getInstance()->set( "Views.Path", $basePath.'/'.$viewPath );
231+
Registry::getInstance()->set( RegistryKeys::VIEWS_PATH, $basePath.'/'.$viewPath );
231232

232233
return parent::onStart();
233234
}
@@ -405,7 +406,7 @@ public function executeController( array $parameters, string $requestName = '' )
405406
{
406407
// Check if this exception should pass through to application-level handlers
407408
// Applications can configure exception classes via neuron.yaml under 'exceptions.passthrough'
408-
$passthroughExceptions = Registry::getInstance()->get( 'PassthroughExceptions' ) ?? [];
409+
$passthroughExceptions = Registry::getInstance()->get( RegistryKeys::PASSTHROUGH_EXCEPTIONS_LEGACY ) ?? [];
409410

410411
if( in_array( get_class( $e ), $passthroughExceptions ) )
411412
{
@@ -512,14 +513,14 @@ protected function loadRoutingConfig(): void
512513
// If routing.yaml exists, it takes precedence even if controller_paths is not defined
513514
if( isset( $config['controller_paths'] ) && is_array( $config['controller_paths'] ) )
514515
{
515-
Registry::getInstance()->set( 'Routing.ControllerPaths', $config['controller_paths'] );
516+
Registry::getInstance()->set( RegistryKeys::ROUTING_CONTROLLER_PATHS, $config['controller_paths'] );
516517
Log::debug( "Loaded " . count( $config['controller_paths'] ) . " controller path(s) from routing.yaml" );
517518
}
518519
else
519520
{
520521
// routing.yaml exists but doesn't define controller_paths
521522
// Set to empty array to prevent fallback to neuron.yaml
522-
Registry::getInstance()->set( 'Routing.ControllerPaths', [] );
523+
Registry::getInstance()->set( RegistryKeys::ROUTING_CONTROLLER_PATHS, [] );
523524
Log::debug( "routing.yaml exists but has no controller_paths defined (no fallback to neuron.yaml)" );
524525
}
525526
}
@@ -538,7 +539,7 @@ protected function loadRoutingConfig(): void
538539
protected function loadAttributeRoutes(): void
539540
{
540541
// Try to get controller paths from routing.yaml (via Registry)
541-
$controllerPaths = Registry::getInstance()->get( 'Routing.ControllerPaths' );
542+
$controllerPaths = Registry::getInstance()->get( RegistryKeys::ROUTING_CONTROLLER_PATHS );
542543

543544
// Fall back to neuron.yaml for backward compatibility
544545
// Use === null to distinguish between "not set" and "explicitly empty array"
@@ -725,7 +726,7 @@ protected function configureRateLimit(): void
725726
*/
726727
public function clearExpiredCache(): int
727728
{
728-
$cache = Registry::getInstance()->get( 'ViewCache' );
729+
$cache = Registry::getInstance()->get( RegistryKeys::VIEW_CACHE_LEGACY );
729730

730731
if( $cache instanceof \Neuron\Mvc\Cache\ViewCache )
731732
{

src/Mvc/Views/Html.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Neuron\Core\Exceptions\NotFound;
88
use Neuron\Core\NString;
9+
use Neuron\Core\Registry\RegistryKeys;
910
use Neuron\Log\Log;
1011
use Neuron\Patterns\Registry;
1112

@@ -34,11 +35,11 @@ public function render( array $data ): string
3435
}
3536

3637
$path = Registry::getInstance()
37-
->get( "Views.Path" );
38+
->get( RegistryKeys::VIEWS_PATH );
3839

3940
if( !$path )
4041
{
41-
$basePath = Registry::getInstance()->get( "Base.Path" );
42+
$basePath = Registry::getInstance()->get( RegistryKeys::BASE_PATH );
4243
$path = "$basePath/resources/views";
4344
}
4445

src/Mvc/Views/Markdown.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use League\CommonMark\MarkdownConverter;
1313
use Neuron\Core\Exceptions\NotFound;
1414
use Neuron\Core\NString;
15+
use Neuron\Core\Registry\RegistryKeys;
1516
use Neuron\Patterns\Registry;
1617

1718
/**
@@ -39,11 +40,11 @@ public function render( array $data ): string
3940
}
4041

4142
$path = Registry::getInstance()
42-
->get( "Views.Path" );
43+
->get( RegistryKeys::VIEWS_PATH );
4344

4445
if( !$path )
4546
{
46-
$basePath = Registry::getInstance()->get( "Base.Path" );
47+
$basePath = Registry::getInstance()->get( RegistryKeys::BASE_PATH );
4748
$path = "$basePath/resources/views";
4849
}
4950

src/Mvc/Views/ViewDataProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Neuron\Mvc\Views;
44

5+
use Neuron\Core\Registry\RegistryKeys;
56
use Neuron\Patterns\Registry;
67

78
/**
@@ -60,7 +61,7 @@ public static function getInstance(): ViewDataProvider
6061
if( self::$_instance === null )
6162
{
6263
self::$_instance = new self();
63-
Registry::getInstance()->set( 'ViewDataProvider', self::$_instance );
64+
Registry::getInstance()->set( RegistryKeys::VIEW_DATA_PROVIDER_LEGACY, self::$_instance );
6465
}
6566

6667
return self::$_instance;

tests/BootstrapTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Tests;
44

5+
use Neuron\Core\Registry\RegistryKeys;
56
use Neuron\Mvc\Application;
67
use Neuron\Patterns\Registry;
78
use org\bovigo\vfs\vfsStream;
@@ -32,8 +33,8 @@ protected function setUp(): void
3233
$this->OriginalEnv = $_ENV ?? [];
3334

3435
// Clear registry
35-
Registry::getInstance()->set( 'Settings', null );
36-
Registry::getInstance()->set( 'Base.Path', null );
36+
Registry::getInstance()->set( RegistryKeys::SETTINGS, null );
37+
Registry::getInstance()->set( RegistryKeys::BASE_PATH, null );
3738
}
3839

3940
protected function tearDown(): void
@@ -92,7 +93,7 @@ public function testBootWithValidConfig()
9293
// Assertions
9394
$this->assertInstanceOf( Application::class, $App );
9495
$this->assertEquals( '1.2.3', $App->getVersion() );
95-
$this->assertNotNull( Registry::getInstance()->get( 'Settings' ) );
96+
$this->assertNotNull( Registry::getInstance()->get( RegistryKeys::SETTINGS ) );
9697
}
9798

9899
/**
@@ -260,7 +261,7 @@ public function testDispatchWithException()
260261
public function testDispatchWithPassthroughException()
261262
{
262263
// Register a custom exception class to pass through
263-
Registry::getInstance()->set( 'PassthroughExceptions', [
264+
Registry::getInstance()->set( RegistryKeys::PASSTHROUGH_EXCEPTIONS_LEGACY, [
264265
'RuntimeException'
265266
] );
266267

@@ -287,7 +288,7 @@ public function testDispatchWithPassthroughException()
287288
public function testDispatchWithNonPassthroughException()
288289
{
289290
// Register a specific exception class to pass through (not the one we'll throw)
290-
Registry::getInstance()->set( 'PassthroughExceptions', [
291+
Registry::getInstance()->set( RegistryKeys::PASSTHROUGH_EXCEPTIONS_LEGACY, [
291292
'LogicException' // Different from what we'll throw
292293
] );
293294

tests/Mvc/ApplicationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Neuron\Core\Exceptions\BadRequestMethod;
77
use Neuron\Core\Exceptions\MissingMethod;
88
use Neuron\Core\Exceptions\NotFound;
9+
use Neuron\Core\Registry\RegistryKeys;
910
use Neuron\Data\Settings\Source\Yaml;
1011
use Neuron\Mvc\Application;
1112
use Neuron\Mvc\Events\Http404;
@@ -97,7 +98,7 @@ public function testConfig()
9798

9899
$this->assertEquals(
99100
"examples/views",
100-
Registry::getInstance()->get( "Views.Path" )
101+
Registry::getInstance()->get( RegistryKeys::VIEWS_PATH )
101102
);
102103
}
103104

tests/Mvc/Controllers/BaseTest.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Neuron\Mvc\Application;
66
use Neuron\Mvc\Controllers\Base;
77
use Neuron\Routing\RequestMethod;
8+
use Neuron\Core\Registry\RegistryKeys;
89
use PHPUnit\Framework\TestCase;
910

1011
class ControllerTest extends Base
@@ -123,7 +124,7 @@ public function testUrlForAbsolute()
123124
$App = new Application( "test" );
124125
$Controller = new ControllerTest( $App );
125126

126-
\Neuron\Patterns\Registry::getInstance()->set( 'Base.Url', 'https://example.com' );
127+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::BASE_URL, 'https://example.com' );
127128

128129
// Add a named route
129130
$route = $App->getRouter()->get( '/users/:id', function() {} );
@@ -192,7 +193,7 @@ public function testMagicCallForUrlMethod()
192193
$App = new Application( "test" );
193194
$Controller = new ControllerTest( $App );
194195

195-
\Neuron\Patterns\Registry::getInstance()->set( 'Base.Url', 'https://test.com' );
196+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::BASE_URL, 'https://test.com' );
196197

197198
// Add a named route
198199
$route = $App->getRouter()->get( '/users/:id', function() {} );
@@ -297,8 +298,8 @@ public function testInitializeViewCacheWithoutSettings()
297298
$Controller = new ControllerTest( $App );
298299

299300
// Clear Registry to simulate no settings
300-
\Neuron\Patterns\Registry::getInstance()->set( 'Settings', null );
301-
\Neuron\Patterns\Registry::getInstance()->set( 'ViewCache', null );
301+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::SETTINGS, null );
302+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::VIEW_CACHE_LEGACY, null );
302303

303304
$reflection = new \ReflectionClass( $Controller );
304305
$method = $reflection->getMethod( 'initializeViewCache' );
@@ -315,8 +316,8 @@ public function testHasViewCacheWithoutCache()
315316
$Controller = new ControllerTest( $App );
316317

317318
// Clear ViewCache from Registry
318-
\Neuron\Patterns\Registry::getInstance()->set( 'ViewCache', null );
319-
\Neuron\Patterns\Registry::getInstance()->set( 'Settings', null );
319+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::VIEW_CACHE_LEGACY, null );
320+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::SETTINGS, null );
320321

321322
$reflection = new \ReflectionClass( $Controller );
322323
$method = $reflection->getMethod( 'hasViewCache' );
@@ -333,8 +334,8 @@ public function testGetViewCacheWithoutCache()
333334
$Controller = new ControllerTest( $App );
334335

335336
// Clear ViewCache from Registry
336-
\Neuron\Patterns\Registry::getInstance()->set( 'ViewCache', null );
337-
\Neuron\Patterns\Registry::getInstance()->set( 'Settings', null );
337+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::VIEW_CACHE_LEGACY, null );
338+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::SETTINGS, null );
338339

339340
$reflection = new \ReflectionClass( $Controller );
340341
$method = $reflection->getMethod( 'getViewCache' );
@@ -351,8 +352,8 @@ public function testIsCacheEnabledByDefault()
351352
$Controller = new ControllerTest( $App );
352353

353354
// Clear cache from Registry
354-
\Neuron\Patterns\Registry::getInstance()->set( 'ViewCache', null );
355-
\Neuron\Patterns\Registry::getInstance()->set( 'Settings', null );
355+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::VIEW_CACHE_LEGACY, null );
356+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::SETTINGS, null );
356357

357358
$reflection = new \ReflectionClass( $Controller );
358359
$method = $reflection->getMethod( 'isCacheEnabledByDefault' );
@@ -370,8 +371,8 @@ public function testHasViewCacheByKeyWithoutCache()
370371
$Controller = new ControllerTest( $App );
371372

372373
// Clear ViewCache from Registry
373-
\Neuron\Patterns\Registry::getInstance()->set( 'ViewCache', null );
374-
\Neuron\Patterns\Registry::getInstance()->set( 'Settings', null );
374+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::VIEW_CACHE_LEGACY, null );
375+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::SETTINGS, null );
375376

376377
$reflection = new \ReflectionClass( $Controller );
377378
$method = $reflection->getMethod( 'hasViewCacheByKey' );
@@ -388,8 +389,8 @@ public function testGetViewCacheByKeyWithoutCache()
388389
$Controller = new ControllerTest( $App );
389390

390391
// Clear ViewCache from Registry
391-
\Neuron\Patterns\Registry::getInstance()->set( 'ViewCache', null );
392-
\Neuron\Patterns\Registry::getInstance()->set( 'Settings', null );
392+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::VIEW_CACHE_LEGACY, null );
393+
\Neuron\Patterns\Registry::getInstance()->set( RegistryKeys::SETTINGS, null );
393394

394395
$reflection = new \ReflectionClass( $Controller );
395396
$method = $reflection->getMethod( 'getViewCacheByKey' );

0 commit comments

Comments
 (0)