Cakephp 2 RequestHandlerComponent没有beforeRender错误消息的方法,无法解析RSS

时间:2013-04-08 03:58:32

标签: cakephp cakephp-2.3 requesthandler

我遇到了两个不同的问题:

  1. 呈现默认请求(html)时出错
  2. 渲染rss请求时出错。
  3. 这是我的代码:

    class PagesController extends AppController {
        public $name = 'Pages';
        public $components = array('RequestHandler');
        public $helpers = array('Text');
    }
    

    以下是正常请求的代码。

      //problem #1:
      public function display() { 
        $path = func_get_args();
    
        $count = count($path);
        if (!$count) {
                $this->redirect('/');
        }
    
        $page = $subpage = $title_for_layout = null;
    
        if (!empty($path[0])) {
                $page = $path[0];
        }
    
        if (!empty($path[1])) {
                $subpage = $path[1];
        }
    
        if (!empty($path[$count - 1])) {
                $title_for_layout = Inflector::humanize($path[$count - 1]);
        }
    
        $this->setDefaultMeta();
        $this->layout = 'default';
        $this->set(compact('page', 'subpage', 'title_for_layout'));
        $this->render(implode('/', $path));
    } 
    

    这是针对rss请求的

     public function feeds(){  
        if( $this->RequestHandler->isRss() ){ 
            $this->loadModel('Deal');
            $arrId = $this->Deal->DealBuyCondition->listAliveID();
    
            $posts = $this->Deal->rssFeeds($arrId);  
            return $this->set(compact('posts'));
        }
        die('rss only');
        return false;
    }
    

    第一个函数返回错误:

    Warning (2): call_user_func_array() expects parameter 1 to be a valid callback, class 'RequestHandlerComponent' does not have a method 'beforeRender' [CORE\Cake\Utility\ObjectCollection.php, line 132]
    
    Warning (2): call_user_func_array() expects parameter 1 to be a valid callback, class 'RequestHandlerComponent' does not have a method 'shutdown' [CORE\Cake\Utility\ObjectCollection.php, line 132]
    

    并且第二个函数没有正确呈现为RSS。

    请帮忙。

1 个答案:

答案 0 :(得分:0)

你的CakePHP设置可能搞砸了。 RequestHandlerComponent确实有beforeRender方法和shutdown方法(继承自父Component),因此这些错误很奇怪。尝试获取CakePHP的新副本。