2014-02-16 3 views
1

나는 이것이 충분히 간단하다고 생각합니다. 난 중첩 페이지에 대한 RoutingAutoBundle을 사용하고 싶습니다.RoutingAutoBundle이 포함 된 중첩 된 경로 (Symfony CMF)

내가 여기 함께 다음있어

http://symfony.com/doc/current/cmf/cookbook/creating_a_cms/ 내가 부모가 Page 문서를 말한다.

/** 
* 
* @PHPCR\Document(referenceable=true) 
* 
* @author Matt Durak <[email protected]> 
*/ 
class Page implements RouteReferrersReadInterface 
{ 
    /** 
    * @PHPCR\Id() 
    */ 
    protected $id; 

    /** 
    * @PHPCR\ParentDocument() 
    */ 
    protected $parent; 

    //... 

    /** 
    * Get ID 
    * 
    * @return integer 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 

    public function getParent() 
    { 
     return $this->parent; 
    } 

    public function setParent($parent) 
    { 
     $this->parent = $parent; 

     return $this; 
    } 

    // ... 
} 

내 자동 라우팅 구성과 같이이다 : 나는 다음과 같은 것을 싶습니다

cmf_routing_auto: 
    mappings: 
     Study\MainBundle\Document\Page: 
      content_path: 
       pages: 
        provider: [specified, { path: /cms/routes/page }] 
        exists_action: auto_increment 
        not_exists_action: create 
      content_name: 
       provider: [content_method, { method: getTitle }] 
       exists_action: auto_increment 
       not_exists_action: create 

. 나는 그렇게처럼 내 데이터를 가정

/cms/pages 
    /page-1 
    /page-2 
     /page-A 
     /page-B 

현재는 이들 4 페이지는 다음과 같은 경로

있을 것 이
/page/page-1 
/page/page-2 
/page/page-A 
/page/page-B 

내가 다른 content_path에 추가하려고했습니다

/page/page-1 
/page/page-2 
/page/page-2/page-A 
/page/page-2/page-B 

싶습니다 content_object 공급자와 전화 getParent,하지만 그 작동하지 않았다. 누구나 Symfony CMF와 RoutingAutoBundle에 익숙한가요? 문서가 희박합니다 ...

+0

URL의 모습은 어떻습니까? (btw, 번들은 완전히 문서화되어 있지만 아직 베타 버전이므로 일부 팁과 트릭의 arricles가 누락되었습니다.) –

+0

내가 본 루트와 내가 원하는 루트를 추가했습니다. 예, 설명서에는 기본 이상의 유용한 예제가 누락되었습니다. 그게 정말 도움이 될 것입니다 – Matt

답변

1

content_method 공급자를 사용하고 클래스에서 null 또는 부모를 반환 할 수 있습니다. RoutingAutoBundle alpha10 현재, 프로 바이더는 패스에 아무것도 추가 할 수 없습니다. 또한 content_object를 사용할 수

cmf_routing_auto: 
    mappings: 
     Study\MainBundle\Document\Page: 
      content_path: 
       pages: 
        provider: [specified, { path: /cms/routes/page }] 
        exists_action: auto_increment 
        not_exists_action: create 
       parent: 
        provider: [content_method, { method: getParentPath }] 
        exists_action: use 
        not_exists_action: create 
      content_name: 
       provider: [content_method, { method: getTitle }] 
       exists_action: auto_increment 
       not_exists_action: create 
class Page 
{ 
    // ... 

    public function getParentPath() 
    { 
     return $this->parent instanceof static ? $this->parent->getTitle() : null; 
    } 
} 

하지만, 하나는 번들에서 제거 될 예정입니다 :

코드는 같을 것이다.

+0

'null'은 효과가없는 것 같습니다. 빈 문자열을 반환하면 허용되지 않는다고 말합니다. "Notice : 정의되지 않은 변수 : D : \ web_workspace \ study \ vendor \ symfony-cmf \ 라우팅 자동 번들 \ Symfony \ Cmf \ Bundle \ R에있는 객체 outingAutoBundle \ AutoRoute \ PathProvider \ ContentMethodProvider.php on line 82" – Matt