У меня проблема с перенаправлением в slim v3.11.0.Когда я вызываю перенаправление на маршруте или из промежуточного программного обеспечения, оно работает как положено.Однако, когда я вызываю его с моего контроллера, он не перенаправляет и не выдает ошибку.Любая помощь будет принята с благодарностью!Спасибо!
* Ref https://www.slimframework.com/docs/v3/start/upgrade.html#changes-to-redirect
пример маршрута (работы)
$app->get('/login/', function ($request, $response, $args) use($app) {
return $response->withRedirect('/new-url');
});
пример промежуточного программного обеспечения (работы)
$auth = function ($request, $response, $next) {
if (!isset($_SESSION['Account'])) {
return $response->withStatus(302)->withHeader('Location', '/new-url/');
}
};
пример контроллера (без работы)
$app->get('/login/', function ($request, $response, $args) use($app) {
return (new Login($app))->TestLoginRedirect();
});
....
class Login {
protected $App;
public function __construct($app){
$this->App = $app;
}
public function TestLoginRedirect(){
return $this->App->getContainer()->response->withRedirect('/new-url');
}
}
Другие попытки фрагмента перенаправления
return $this->App->getContainer()->response->withStatus(301)->withHeader('Location', '/new-url/');
return $this->App->redirect('/', '/new-url/');