2020 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2121 */
2222abstract class BaseRouter {
23+ private ?RouterConfig $ config ;
2324 private Assembly $ viewAssembly ;
2425 private Assembly $ logicAssembly ;
2526 private Container $ container ;
@@ -28,10 +29,26 @@ abstract class BaseRouter {
2829 private bool $ routeCompleted ;
2930
3031 public function __construct (
31- protected ? ConfigSection $ routerConfig = null ,
32+ null | ConfigSection | RouterConfig $ routerConfig = null ,
3233 ?Assembly $ viewAssembly = null ,
3334 ?Assembly $ logicAssembly = null ,
3435 ) {
36+ if ($ routerConfig instanceof ConfigSection) {
37+ trigger_deprecation (
38+ "phpgt/routing " ,
39+ "1.1.4 " ,
40+ "Using ConfigSection type will be removed in a future release - use RouterConfig instead for type safety "
41+ );
42+
43+ $ this ->config = new RouterConfig (
44+ $ routerConfig ->getInt ("redirect_response_code " ),
45+ $ routerConfig ->getString ("default_content_type " ),
46+ );
47+ }
48+ else {
49+ $ this ->config = $ routerConfig ;
50+ }
51+
3552 $ this ->viewAssembly = $ viewAssembly ?? new Assembly ();
3653 $ this ->logicAssembly = $ logicAssembly ?? new Assembly ();
3754 $ this ->routeCompleted = false ;
@@ -59,7 +76,8 @@ public function handleRedirects(
5976 }
6077
6178 private function determineResponseClass ():string {
62- $ responseCode = $ this ->routerConfig ?->getInt("redirect_response_code " );
79+ $ responseCode = $ this ->config ->redirectResponseCode ;
80+
6381 return match ($ responseCode ) {
6482 300 => HttpMultipleChoices::class,
6583 301 => HttpMovedPermanently::class,
0 commit comments