33namespace PivotPHP \CycleORM \Middleware ;
44
55use PivotPHP \Core \Core \Application ;
6- use PivotPHP \CycleORM \Http \CycleRequest ;
76use PivotPHP \Core \Http \Request ;
87use PivotPHP \Core \Http \Response ;
98
@@ -21,7 +20,7 @@ public function __construct(Application $app)
2120 *
2221 * @param callable(Request, Response):void $next função next do PivotPHP
2322 */
24- public function __invoke (CycleRequest | Request $ req , Response $ res , callable $ next ): void
23+ public function __invoke (Request $ req , Response $ res , callable $ next ): void
2524 {
2625 $ this ->handle ($ req , $ res , $ next );
2726 }
@@ -31,7 +30,7 @@ public function __invoke(CycleRequest|Request $req, Response $res, callable $nex
3130 *
3231 * @param callable(Request, Response):void $next função next do PivotPHP, recebe Request e Response
3332 */
34- public function handle (CycleRequest | Request $ req , Response $ res , callable $ next ): void
33+ public function handle (Request $ req , Response $ res , callable $ next ): void
3534 {
3635 // Use sempre o container PSR-11 para buscar serviços
3736 if (method_exists ($ this ->app , 'getContainer ' )) {
@@ -55,13 +54,8 @@ public function handle(CycleRequest|Request $req, Response $res, callable $next)
5554 $ transactionStarted = true ;
5655 $ this ->logDebug ('Transaction started for route: ' . $ this ->getRouteInfo ($ req ));
5756
58- // If we have a CycleRequest, pass the original request to the next middleware
59- // to ensure compatibility with the route handler
60- if ($ req instanceof CycleRequest) {
61- $ next ($ req ->getOriginalRequest (), $ res );
62- } else {
63- $ next ($ req , $ res );
64- }
57+ // Pass the request to the next middleware
58+ $ next ($ req , $ res );
6559
6660 // Commit apenas se há mudanças
6761 if (is_object ($ em ) && method_exists ($ em , 'commitTransaction ' )) {
@@ -85,20 +79,10 @@ public function handle(CycleRequest|Request $req, Response $res, callable $next)
8579 }
8680 }
8781
88- private function getRouteInfo (CycleRequest | Request $ req ): string
82+ private function getRouteInfo (Request $ req ): string
8983 {
90- $ method = property_exists ($ req , 'method ' )
91- && (is_string ($ req ->method ) || is_numeric ($ req ->method ))
92- ? (string ) $ req ->method
93- : 'Unknown ' ;
94-
95- $ uri = property_exists ($ req , 'pathCallable ' )
96- && (is_string ($ req ->pathCallable ) || is_numeric ($ req ->pathCallable ))
97- ? (string ) $ req ->pathCallable
98- : (property_exists ($ req , 'path ' )
99- && (is_string ($ req ->path ) || is_numeric ($ req ->path ))
100- ? (string ) $ req ->path
101- : 'Unknown ' );
84+ $ method = $ req ->getMethod ();
85+ $ uri = $ req ->getPathCallable ();
10286
10387 return "{$ method } {$ uri }" ;
10488 }
0 commit comments