2013-06-04 3 views
0

나는이 문제에 어려움을 겪고 있으며, 그것을 극복 할 수 없다./rolepermission [/ : 역할 ID]/권한 [/ : permissionid] [/ 액션/: 액션] 젠드 2 프레임 워크 라우팅

은 현재 내가 이런 식으로 뭔가를 내놓았다 :

는 내가 달성하고자하는 것은이 같은 경로가

 'rolepermission' => array(
      'type' => 'literal', 
      'options' => array(
       'route' => '/rolepermission', 
       'constraints' => array(), 
       'defaults' => array(
        'controller' => 'My\Controller\RolePermission', 
        'action' => 'index', 
       ), 
      ), 
      'may_terminate' => true, 
      'child_routes' => array(
       'rolepermissionroleid' => array(
        'type' => 'segment', 
        'options' => array(
         'route' => '/[:roleid]', 
         'constraints' => array(
          'roleid' => '[a-zA-Z][a-zA-Z0-9_-]*', 
         ), 
         'defaults' => array(
          'action' => 'detail', 
         ), 
        ), 
        'may_terminate' => true, 
        'child_routes' => array(
         'rolepermissionpermissions' => array(
          'type' => 'literal', 
          'options' => array(
           'route' => '/permissions', 
           'constraints' => array(), 
           'defaults' => array(
            'action' => 'index' 
           ), 
          ), 
          'may_terminate' => true, 
          'child_routes' => array(
           'rolepermissionpermissionid' => array(
            'type' => 'segment', 
            'options' => array(
             'route' => '/[:permissionid]', 
             'constraints' => array(
              'permissionid' => '[a-zA-Z][a-zA-Z0-9_-]*', 
             ), 
             'defaults' => array(
             ), 
            ), 
            'may_terminate' => true, 
            'child_routes' => array(
             'rolepermissionaction' => array(
              'type' => 'segment', 
              'options' => array(
               'route' => '/action/[:action]', 
               'constraints' => array(
                'action' => '[a-zA-Z][a-zA-Z0-9_-]*', 
               ), 
               'defaults' => array(
                'action' => 'index' 
               ), 
              ), 
              'may_terminate' => false, 
              'child_routes' => array(), 
             ), 
            ), 
           ), 
          ), 
         ), 
        ), 
       ), 
      ), 
     ), 

/rolepermission/permissions로 라우팅 할 때 나는 roleid 대신 'permissions'를 사용합니다. 나는 여기에 roleid를 넘기지 않아서 대체 될 것이 없다고 기대하고 있습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까? 사전에

감사합니다, 환호

+0

이런 식으로 경로를 사용하지는 않지만 'roleid'=> '[a-zA-Z] [a-zA-Z0-9 _-] *'는 영숫자 또는 밑줄이나 하이픈을 허용하도록 설정됩니다. ID 열에 실제로 이러한 문자가 포함되어 있습니까? 나는 당신이 그렇지 않을 때 당신이 roleid에 들어가고 있다고 가정하는 이유 인 것 같아요. 당신은 시도해 볼 수 있고 모든 것을 1로 쓴 다음 나중에 병합하여 이것을 할 수 있습니다. – mic

+0

micb에게 조언 해 주셔서 감사합니다. roleid는 영숫자 ID입니다 (예 : 'Admin'). 루트없이 루트가 아닌 경로를 하나의 경로로 정의 할 때 작동합니다 ('route'=>/rolepermission [/ : roleid]/사용 권한 [/ :/action/: action]). 올바른 경로 일치. – kinkee

답변

1

일시적으로 다음과 같이 'rolepermissionpermissions'아이 경로를 적용하여 문제를 해결 :

'rolepermission' => array(
      'type' => 'segment', 
      'options' => array(
       'route' => '/rolepermission', 
       'constraints' => array(), 
       'defaults' => array(
        'controller' => 'My\Controller\RolePermission', 
        'action' => 'index', 
       ), 
      ), 
      'may_terminate' => true, 
      'child_routes' => array(
       'rolepermissionroleid' => array(
        'type' => 'segment', 
        'options' => array(
         'route' => '/:roleid', 
         'constraints' => array(
          'roleid' => '[a-zA-Z][a-zA-Z0-9_-]*', 
         ), 
         'defaults' => array(
          'action' => 'detail' 
         ), 
        ), 
        'may_terminate' => true, 
        'child_routes' => array(
         'rolepermissionpermissionid' => array(
          'type' => 'segment', 
          'options' => array(
           'route' => '[/permission/:permissionid]', 
           'constraints' => array(
            'permissionid' => '[a-zA-Z][a-zA-Z0-9_-]*', 
           ), 
           'defaults' => array(
            'action' => 'detail', 
           ), 
          ), 
          'may_terminate' => true, 
          'child_routes' => array(
           'rolepermissionaction' => array(
            'type' => 'segment', 
            'options' => array(
             'route' => '/action/:action', 
             'constraints' => array(
              'action' => '[a-zA-Z][a-zA-Z0-9_-]*', 
             ), 
             'defaults' => array(
              'action' => 'detail' 
             ), 
            ), 
            'may_terminate' => true, 
            'child_routes' => array(), 
           ), 
          ), 
         ), 
        ), 
       ), 
      ), 
     ), 

는 참으로 최선의 해결책이 아니다 있지만이 지금은 작동합니다.