2012-09-08 86 views
1

我想擴展symfony的默認路由器。我在lib /中創建了路由文件夾,並且創建了customRouter.class.php,並將其保存在lib/routing下。我已經更改如下factories.yml文件:用symfony 1.4自定義路由

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路由器的解決方案?

+5

在[高級路由](http://www.symfony-project.org)中介紹了symfony 1.4中的自定義路由。/more-with-symfony/1_4/en/02-Advanced-Routing)部分的symfony書。具體而言,關於[創建自定義路由類](http://www.symfony-project.org/more-with-symfony/1_4/en/02-Advanced-Routing#chapter_02_creating_a_custom_route_class)部分應該會有所幫助。 –

+0

@Kenny我已經檢查過那篇文章,但對我沒用。因爲我不使用教條。該文章擴展了sfDoctrineRoute。我必須擴展sfPatternRouting,但我不能。 – user1150508

+1

我使用的是symfony 1.4.11,我做了和你一樣的事情:在lib中路由文件夾,清空customRouter類,更改factories.yml中的設置,清除緩存 - 沒問題,也許你的問題不必與customRouter類本身? –

回答

0

我相信你擴展了錯誤的類,因此不會繼承必要的方法。 symfony 1.4文檔建議擴展'sfDoctrineRoute'類以創建自定義路由(通過@Kenny鏈接)