我遇到了两个不同的问题:
这是我的代码:
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。
请帮忙。
答案 0 :(得分:0)
你的CakePHP设置可能搞砸了。 RequestHandlerComponent
确实有beforeRender
方法和shutdown
方法(继承自父Component
),因此这些错误很奇怪。尝试获取CakePHP的新副本。