从Zend_Router_Route_Regex到可选参数的路由仅返回默认值

时间:2014-01-23 13:55:14

标签: php zend-framework zend-route zend-router

我想创建匹配的路线:

search-results/result_Abc
search-results/result_Abc,11
search-results/result_Abc,2,3,4,6

等等。换句话说 - 我想在链接不提供时使用默认值。 路线如:

search-results/result_([a-zA-Z]+)[,(\d+)]{1,8}

search-results/result_([a-zA-Z]+)(\,\d+){1,8}

有效,但没有从链接中捕获任何参数(我只获得默认值)。

到目前为止,我可以设法编写的只有工作解决方案(需要提供所有参数)列在下面。

new Zend_Controller_Router_Route_Regex(
                        'search-results/result_([a-zA-Z]+),(\d+),(\d+),(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)',
                        array(
                            'module'=>'www',
                            'controller'=>'index', 
                            'action'=>'searchresults', 
                            'city' => 'wszystkie',
                            'distance' => 0,
                            'driversLicense' => 0,
                            'smoking' => 1,
                            'experience' => 0,
                            'languageKnowledge' => 0,
                            'timeDeparture' => 0,
                            'age' => 0,
                            'page' => 1

                            ),               
                        array(
                                '1'=>'city',
                                '2'=>'distance',
                                '3'=>'driversLicense',
                                '4'=>'smoking',
                                '5'=>'experience',
                                '6'=>'languageKnowledge',
                                '7'=>'timeDeparture',
                                '8'=>'age',
                                '9'=>'page'

                            )                                 
                    )

0 个答案:

没有答案