Problem:
Symfony\Component\HttpKernel\Exception\ControllerDoesNotReturnResponseException: The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned null. Did you forget to add a return statement somewhere in your controller? in () (Line 98 in /var/www/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).
Solution (in Controller):
<?php
namespace Drupal\my_module2024\Controller;
use Drupal\Core\Controller\ControllerBase;
use \Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Url;
use Drupal\Core\Link;
use Drupal\Core\Render\Markup;
use Drupal\Core\Access\AccessResult;
class myClass123 extends ControllerBase {
public function my_main_func( )
{
// ... some code
$response = new RedirectResponse( $link, 302);
$response->send();
return $response;
}
}
Important: return $response;
Neuen Kommentar schreiben