2014-01-23 3 views
0

무엇 메신저 달성하기 위해 노력 :ZF2 세그먼트 자식 경로

그래서
domain.com/user     = UserController::index 
domain.com/user/profile   = UserController::profile 
domain.com/user/profile/9   = UserController::profile (with query param id=9) 
domain.com/user/profile/9/edit  = UserController::editProfile (with query param id=9) 

나는 다음과 같은 경로가 : 그것은 일종의 사실을 제외하고, 작동

'user' => array(
    'type' => 'Segment', 
    'options' => array(
     'route' => '/user', 
     'defaults' => array(
      '__NAMESPACE__' => 'YrmUser\Controller', 
      'controller' => 'User', 
      'action'  => 'index', 
     ), 
    ), 
    'may_terminate' => true, 
    'child_routes' => array(
     'profile' => array(
      'type' => 'Segment', 
      'options' => array(
       'route' => '/profile[/:id]', 
       'defaults' => array(
        'action' => 'profile', 
       ), 
       'constraints' => array(
        'id' => '[0-9]*' 
       ), 
      ), 
      'may_terminate' => true, 
      'child_routes' => array(
       'edit' => array(
        'type' => 'Segment', 
        'options' => array(
         'route' => '/edit', 
         'defaults' => array(
          'action' => 'editProfile', 
         ), 
        ), 
        'may_terminate' => true 
       ), 
      ) 
     ), 
    ) 
) 

을 그 쿼리 매개 변수 ID 결코 가치를 얻는다. 내가 메신저 바보 간단하게 그 일을 추측, 잘못된 뭘하는지 말해 줄 수 누구 ... 사전에

감사합니다,

YRM 나를 위해

답변

1

작품.

나는 작업에 $this->params ('id')을 var_dumped이있어 : 매우 어리석은 실수 .. 내가 fromQuery가 fromRoute을 사용해야 사용

/user 
null 

/user/profile 
null 

/user/profile/99 
string '99' (length=2) 

/user/profile/99/edit 
string '99' (length=2) 
+0

는 참이었다 – YRM