在之前的 cakephp-1.2和cakephp-1.3中,我使用了以下代码,它工作正常:
$b = $this->requestAction(
array('controller' => 'blocks', 'action' => 'view'),
array('sParams' => $this->params, 'position' => $position, 'return')
);
现在我使用 cakePHP 2.4.1,这会导致以下错误:
> Warning (2): rawurlencode() expects parameter 1 to be string, object
> given [CORE\Cake\Routing\Router.php, line 1001]
其次是缺少控制器错误:
> Missing Controller
>
> Error: Controller could not be found.
>
> Error: Create the class Controller below in file:
> app\Controller\Controller.php
>
> <?php class Controller extends AppController {
>
> }
从 cakePHP 1.3 到 CakePHP 2.4.1 有什么我不知道的东西会阻止这个 requestAction 像往常一样工作吗?
编辑:在requestAction api 文档中,有以下通知:
在后台,此方法使用 Router::reverse() 将 $url 参数转换为字符串 URL。您应该使用与 Router::reverse() 兼容的 URL 格式
但是,在Router::reverse方法文档中,我找不到任何有关其 URL 兼容格式的提示。
顺便说一句,使用默认布局主题结束了这个问题,他们不使用 requestAction(),但我需要使用主题视图及其布局。