註銷後我想重定向到索引頁,但我得到一個錯誤的FOSUserBundleLogicException:控制器必須返回一個響應(給出null)。你忘了在控制器的某個地方添加一個return語句嗎?
在SecurityController.php
<?php
namespace ispg\Bundle\ChatBundle\Controller;
namespace FOS\UserBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
class SecurityController extends ContainerAware
{
public function loginAction()
{
$request = $this->container->get('request');
/* @var $request \Symfony\Component\HttpFoundation\Request */
$session = $request->getSession();
/* @var $session \Symfony\Component\HttpFoundation\Session */
$network = $request->get("network");
// get the error if any (works with forward and redirect -- see below)
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} elseif (null !== $session && $session->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = '';
}
if ($error) {
// TODO: this is a potential security risk (see http://trac.symfony-project.org/ticket/9523)
$error = $error->getMessage();
}
// last username entered by the user
$lastUsername = (null === $session) ? '' : $session->get(SecurityContext::LAST_USERNAME);
//create the select tag for network selection
require 'mnoNetworks.php';
$selectHtml = "<select id=\"networks\">
<option value=\"\"> -- Select -- </option>";
foreach($networks as $network){
$selectHtml .= "<option value=\"".$network."\">".$network."</option>";
}
$selectHtml .="</select>";
return $this->container->get('templating')->renderResponse('FOSUserBundle:Security:login.html.'.$this->container->getParameter('fos_user.template.engine'), array(
'last_username' => $lastUsername,
'error' => $error,
'network' => $network,
'networkSelector' => $selectHtml
));
}
public function checkAction()
{
throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
}
public function logoutAction()
{
$bundle2 = new \ispg\Bundle\ChatBundle\Controller\DefaultController();
$bundle2->setContainer($this->container);
$returned_data = $bundle2->san();
}
}
logoutAction會議後,我想重定向到索引頁
如何重定向到它。
任何人都可以解決這個問題嗎?
其表示錯誤:致命錯誤:類 'FOS \ UserBundle \控制器\的Symfony \元器件\ HttpFoundation \ RedirectResponse' 不FO und in line 77上的/var/www/html/pan.ispghosting.com/phpver3/mno/vendor/bundles/FOS/UserBundle/Controller/SecurityController.php – Jethik