是否可以删除Zend Framework 2中的嵌套视图


Is it possible to remove a nested view in Zend Framework 2?

我有一些从类的父级继承的嵌套视图,希望从中删除一个子级。。。例如,父代码:

    Class Father
    {
        public function IndexAction()
        {
            ...
            $view = new ViewModel();
            $view->addChild($viewToNest);
            return $view;
        }
    }

扩展示例:

    Class Son extends Father
    {
        //This is supposed to override
        public function IndexAction()
        {
            $view = parent::IndexAction();
            #Is there anything like this?
            $view->removeChild();
            return $view;
        }
    }

有人知道办法吗?

在文档中,指定可以使用$view->clearChildren()清除所有子项。

再次根据文件,似乎没有什么可以移除特定的孩子。你必须自己做。