0

这里的顶级路由器有效。/property 是一个字面量路由,它不会终止并在子路由上执行 GET 操作。在此之下,我有一个段路由,就像它的父级一样,它不会终止并在子路由上执行 GET 操作。它应该只在 /property/12 上响应 GET 请求

在那里路由时出现未找到的错误。

'router' => array(
    'routes' => array(
        'property' => array(
            'type'    => 'Literal',
            'options' => array(
                'route'    => '/property',
            ),
            'may_terminate' => false,
            'child_routes' => array(
                'get' => array(
                    'type' => 'method',
                    'options' => array(
                        'verb' => 'GET',
                        'defaults' => array(
                            'controller' => 'Property\Controller\Rest',
                            'action' => 'get',
                        ),
                    ),
                ),
                'by_id' => array(
                    'type' => 'segment',
                    'options' => array(
                        'route' => '/[:propertyId]',
                        'may_terminate' => false,
                        'child_routes' => array(
                            'get_by_id' => array(
                                'type' => 'method',
                                'options' => array(
                                    'verb' => 'GET',
                                    'defaults' => array(
                                        'controller' => 'Property\Controller\Rest',
                                        'action' => 'getById',
                                    ),
                                ),
                            ),
                        )
                    ),
                ),
4

1 回答 1

2

您的数组无效。'may_terminate'不应该在里面'options'。不确定这是否会导致您的所有问题,但请尝试更新并查看是否已解决:

            'by_id' => array(
                'type' => 'segment',
                'options' => array(
                    'route' => '/[:propertyId]'
                ),
                'may_terminate' => false,
                'child_routes' => array(
                    'get_by_id' => array(
                        'type' => 'method',
                        'options' => array(
                            'verb' => 'GET',
                            'defaults' => array(
                                'controller' => 'Property\Controller\Rest',
                                'action' => 'getById'
                            )
                        )
                    )
                )
            ),
于 2015-07-28T08:50:05.853 回答