2016-09-15 3 views
0

관련 항목이있는 엔티티 (질문)를 만드는 경로를 제공하는 확장이 있습니다 (각 항목에는 0, 1 또는 여러 가지 관련 질문이 있음).Doctrine/Bolt와의 ContentType 관계 처리 EM

볼트의 save/doctrine의 persist 메소드를 실제로 관계를 유지하는 것처럼 보이지 않습니다. 나는 해봤 다음

$question = $repo->create([ 
    'question' => $request->get('question', 'What is love?'), 
    'status' => 'draft', 
    'entries' => [$entry] 
]); 

$question->relation->add($entry)

$question->setRelation(new Collection\Relations([$entry], $em))

(편집) 나는 또한 아래의 응답 당

$entry = $em->find('entries', $request->get('entry', 1)); 
$related = $em->createCollection('Bolt\Storage\Entity\Relations'); 
$related->add(new Relations([ 
    'from_contenttype' => $question->getContenttype(), 
    'from_id' => $question->getId(), 
    'to_contenttype' => $entry->getContenttype(), 
    'to_id' => $entry->getId() 
])); 

$question->setRelation($relation); 

을 시도했습니다,하지만 여전히하지 않습니다 작업.

아무 것도 작동하지 않습니다. Question (Content) 엔티티는 올바르게 저장하지만 관계는 올바르게 저장하지 않습니다. ... 당장은 정말 확실하지

답변

0

내가 수행 한 테스트가 있는데, 구문이 추한 것을 알고 있으며, 계획이 더 많은 도우미 메서드를 추가하는 것이지만 작동하지 않습니다.

$repo = $app['storage']->getRepository('pages'); 

$newPage = $repo->create( 
    [ 
     "title" => 'An Example Title', 
     "slug" => 'an-example-title', 
     "status" => 'published', 
     "teaser" => 'An intro teaser goes here', 
     "body" => 'Lorem ipsum dolor sit amet, consectet adipisici.', 
    ] 
); 

$newPage->getRelation()->setFromPost(['entries' => [1]], $newPage); 
$repo->save($newPage); 
관련 문제