1 回答
TA貢獻1803條經驗 獲得超6個贊
據我所知,在Documents.
因此,任何給定的文檔都可以與許多其他文檔相關。
linkedDocuments只是保存 的集合的變量的名稱Documents。
我的觀點是鏈接的文檔不是類型linkedDocumentsbut Documents,所以你的類型提示應該相應地改變:
/**
* @return Collection|Document[]
*/
public function getlinkedDocuments(): Collection
{
return $this->linkedDocuments;
}
public function addlinkedDocument(Document $linkedDocument): self
{
if (!$this->linkedDocuments->contains($linkedDocument)) {
$this->linkedDocuments[] = $linkedDocument;
}
return $this;
}
public function removelinkedDocument(Document $linkedDocument): self
{
if ($this->linkedDocuments->contains($linkedDocument)) {
$this->linkedDocuments->removeElement($linkedDocument);
}
return $this;
}
編輯:根據 Cerad 的建議,我已經去重命名方法以更好地反映多元化。所以你的類應該被調用,Document以便任何一個給定的文檔都可以鏈接到許多文檔。
- 1 回答
- 0 關注
- 150 瀏覽
添加回答
舉報
