중첩 된 embedRelation() 인스턴스에 대한 일부 조건문을 설정하려고하고 있으며 두 번째 embedRelation까지 어떤 종류의 옵션도 얻을 수있는 방법을 찾을 수 없습니다. .symfony : 여러 수준의 관계 중첩을위한 embedRelation() 제어
"Measure-> Page-> Question"테이블 관계가 있고 Question 테이블을 표시할지 여부를 선택할 수 있어야합니다. 예를 들어, page1Success.php와 page2Success.php라는 두 개의 "성공"페이지가 있다고 가정 해보십시오. 1 페이지에서 "Measure-> Page-> Question"을 표시하고 2 페이지에서 "Measure-> Page"를 표시하고 싶지만 PageForm에 "option"을 전달할 방법이 필요합니다. .class.php 파일을 작성하여 그러한 종류의 결정을 내리십시오. 작동하지 않습니다 "질문"에
// actions.class.php
$this->form = new measureForm($measure, array('option'=>$option));
은 "페이지"에 옵션을 전달하지만, "페이지"를 통해 해당 옵션을 통과 : 내 actions.class.php 파일은 다음과 같이 있습니다.
내 measureForm.class.php 파일은 "옵션"에 의존 그것의 embedRelation 있습니다
// measureForm.class.php
if ($this->getOption('option') == "page_1") {
$this->embedRelation('Page');
}
를이 내가 내 pageForm.class에서 할 같은 을 거라고 것입니다. PHP 파일 :
// pageForm.class.php
if ($this->getOption('option') == "page_1") { // Or != "page_2", or whatever
$this->embedRelation('Question');
}
나는 이것을 할 방법을 찾을 수 없습니다. 어떤 아이디어?
embedRelation없이이 유형의 작업을 수행하는 데 선호되는 Symfony 방식이 있습니까? 나는() 대신 embedForm를 사용하기로 결정했습니다
# schema.yml
Measure:
connection: doctrine
tableName: measure
columns:
_kp_mid:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
description:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
frequency:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Page:
local: _kp_mid
foreign: _kf_mid
type: many
Page:
connection: doctrine
tableName: page
columns:
_kp_pid:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
_kf_mid:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
next:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
number:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
previous:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Measure:
local: _kf_mid
foreign: _kp_mid
type: one
Question:
local: _kp_pid
foreign: _kf_pid
type: many
Question:
connection: doctrine
tableName: question
columns:
_kp_qid:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
_kf_pid:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
text:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
type:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Page:
local: _kf_pid
foreign: _kp_pid
type: one
나는 당신이 달성하려고하는 것에 대해 약간 분명하지 않기 때문에 당신의 질문에 샘플 스키마를 넣을 수 있습니다. – johnwards
물론 문제는 없습니다. 나는 또한 많은 정보를 더 명확하게 업데이트했다. – wulftone