Php 在过滤器中使用“前进”时,整个布局将渲染两次

Php 在过滤器中使用“前进”时,整个布局将渲染两次,php,symfony-1.4,Php,Symfony 1.4,奇怪,但这是真的。My filters.yml: # You can find more information about this file on the symfony website: # http://www.symfony-project.org/reference/1_4/en/12-Filters rendering: ~ security: ~ # insert your own filters here myFilter: class: myFilter cac

奇怪,但这是真的。My filters.yml:

# You can find more information about this file on the symfony website:
# http://www.symfony-project.org/reference/1_4/en/12-Filters

rendering: ~
security:  ~

# insert your own filters here

myFilter:
  class: myFilter

cache:     ~
execution: ~
这个过滤器:

<?php
class MyFilter extends sfFilter
{
    /**
     * @return
     */
    public function execute ($filterChain)
    {
        if ($this->isFirstCall())
        {
            if NOT LOGGED IN
            {
                $this->getContext()->getUser()->setFlash ('error', 'login again!');
                $this->getContext()->getController()->forward('glbl', 'empty');
            }
        }

        $filterChain->execute();
    }
}
?>

我想要什么?while站点始终需要一个登录用户,或者您只能看到登录页面。当您未登录或同时注销时,URL必须保留,并获得登录页面,您应该会看到一个“空”模块(登录部分显示在其他地方)


但它会渲染整个布局两次。即使是
标记也是重复的。有什么问题吗?

尝试将
->向前(
更改为
->重定向(
尝试添加

throw new sfStopException();
转发后:

<?php
class MyFilter extends sfFilter
{
    /**
     * @return
     */
    public function execute ($filterChain)
    {
        if ($this->isFirstCall())
        {
            if NOT LOGGED IN
            {
                $this->getContext()->getUser()->setFlash ('error', 'login again!');
                $this->getContext()->getController()->forward('glbl', 'empty');
                throw new sfStopException();
            }
        }

        $filterChain->execute();
    }
}
?>


与此处完全相同:我想您不需要这个,请阅读您之前的问题。没关系,但URL会发生变化……我不想让它找到另一种解决方案:@user1929946
return
throw new sfStopException();
在此处执行基本相同的操作:停止其余的筛选器。