2014-07-16 5 views
1

젠드 프레임 워크 2에서 사용자 지정 라우팅을 작성하고 싶습니다. 이 같은젠드 프레임 워크 2 + 매개 변수가있는 라우팅

'objects' => array(
      'type' => 'Literal', 
      'options' => array(
       'route' => '/objects', 
       'defaults' => array(
        '__NAMESPACE__' => 'Application\Controller', 
        'controller' => 'Index', 
        'action' => 'decode', 
       ), 
      ), 
      'may_terminate' => true, 
      'child_routes' => array(
       'default' => array(
        'type' => 'Segment', 
        'options' => array(
         'route' => '/[:mask]', 
         'constraints' => array(
          'mask' => '[a-zA-Z][a-zA-Z0-9_-.,]*', 
         ), 
         'defaults' => array(

         ), 
        ), 
       ), 
      ), 
     ), 

내가 라우팅합니다 ADRES : 나는 다음과 같은 코드를 준비

http://restaurations.en/objects/크 라 카우, 0.html을

http://restaurations.en/objects/크 라 카우, 수영, 1.html

http : restaurations.en/objects/swam, 3.html

블로 우 텍스트는 내 컨트롤러에 있어야합니다. 또한, 어떻게 코어 라우터를 준비해야합니까 ?? 내가 어떻게 해? 당신이해야 PARAM 얻기 위해 컨트롤러에서 다음

'objects' => array(
     'type' => 'Literal', 
     'options' => array(
      'route' => '/objects', 
      'defaults' => array(
       '__NAMESPACE__' => 'Application\Controller', 
       'controller' => 'Index', 
       'action' => 'decode', 
      ), 
     ), 
     'may_terminate' => true, 
     'child_routes' => array(
      'default' => array(
       'type' => 'Segment', 
       'options' => array(
        'route' => '/[:mask]', 
        'constraints' => array(
         'mask' => '[a-zA-Z][a-zA-Z0-9_-.,]*', 
        ), 
        'defaults' => array(
          '__NAMESPACE__' => 'Application\Controller', 
          'controller' => 'Index', 
          'action' => 'decode', 
        ), 
       ), 
      ), 
     ), 
    ), 

을 :

답변

0

는이 같은 기본값뿐만 아니라 무언가를 추가해야

$mask = $this->params()->fromRoute('mask'); 
+0

확인을하지만 난 plugings을 사용할 수 없습니다. 경고 : preg_match() : 컴파일 실패 : C : \ wamp \ www \ restauracje \ vendor \ ZendFramework-2.2.0 \ library \의 오프셋 37에있는 문자 클래스의 순서가 잘못되었습니다. Zend \ Mvc \ Router \ Http \ Segment.php on line 370 – user3725172

+0

'경로'=> '/ [: 마스크] .html', '제약'=> 배열 ( '마스크'=> '[ ZA-Z] [a-zA-Z0-9 _-,] + ', ), – peterpeterson

+0

실수로 죄송합니다. 실수로 붙여 넣기에 대한 텍스트가 붙여졌습니다. :) – peterpeterson