【发布时间】:2012-09-08 01:47:31
【问题描述】:
我想扩展 symfony 的默认路由器。我在 lib/ 中创建了路由文件夹,并创建了 customRouter.class.php 将其保存在 lib/routing 下。我已将 factory.yml 更改如下:
all:
routing:
class: customRouter
我的 customRouter.class.php 是:
class customRouter extends sfPatternRouting{
}
我只扩展 sfPatternRouting 类。当我运行应用程序时,它给我一个错误如下:
Catchable fatal error: Argument 1 passed to sfRouting::__construct() must be an instance of sfEventDispatcher, string given in /opt/task/lib/vendor/symfony/lib/routing/sfRouting.class.php on line 32
我没有意识到这个问题。我只扩展课程。 symfony的路由器扩展有什么办法?
【问题讨论】:
-
symfony 1.4 中的自定义路由在 symfony 手册的Advanced Routing 部分中有所介绍。具体来说,Creating a Custom Route Class 部分应该会有所帮助。
-
@Kenny 我已经检查过那篇文章,但对我来说没用。因为我不使用教义。那篇文章正在扩展 sfDoctrineRoute。我必须扩展 sfPatternRouting 但我不能。
-
我正在使用 symfony 1.4.11,我做了和你一样的事情:lib 中的路由文件夹,空的 customRouter 类,更改 factory.yml 中的设置,清除缓存 - 没问题,也许是你的问题与customRouter类本身无关?
-
在构造函数中使用变量之前,只需调试变量中的确切内容,我确定您必须跟踪问题的开始位置。
标签: symfony1 symfony-1.4