mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-29 07:26:05 +00:00
setParent methods entity support
This commit is contained in:
@@ -189,16 +189,28 @@ class Attachment extends Entity
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setParent(?LinkParent $parent): self
|
||||
public function setParent(LinkParent|Entity|null $parent): self
|
||||
{
|
||||
$this->setValueObject('parent', $parent);
|
||||
if ($parent instanceof LinkParent) {
|
||||
$this->setValueObject('parent', $parent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->relations->set('parent', $parent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRelated(?LinkParent $related): self
|
||||
public function setRelated(LinkParent|Entity|null $related): self
|
||||
{
|
||||
$this->setValueObject('related', $related);
|
||||
if ($related instanceof LinkParent) {
|
||||
$this->setValueObject('related', $related);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->relations->set('related', $related);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -632,9 +632,15 @@ class Email extends Entity
|
||||
return $this->getValueObject('parent');
|
||||
}
|
||||
|
||||
public function setParent(?LinkParent $parent): self
|
||||
public function setParent(LinkParent|Entity|null $parent): self
|
||||
{
|
||||
$this->setValueObject('parent', $parent);
|
||||
if ($parent instanceof LinkParent) {
|
||||
$this->setValueObject('parent', $parent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->relations->set('parent', $parent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -224,24 +224,42 @@ class Note extends Entity
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setParent(LinkParent $parent): self
|
||||
public function setParent(LinkParent|Entity $parent): self
|
||||
{
|
||||
$this->setValueObject('parent', $parent);
|
||||
if ($parent instanceof LinkParent) {
|
||||
$this->setValueObject('parent', $parent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->relations->set('parent', $parent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRelated(LinkParent $related): self
|
||||
public function setRelated(LinkParent|Entity $related): self
|
||||
{
|
||||
$this->setValueObject('related', $related);
|
||||
if ($related instanceof LinkParent) {
|
||||
$this->setValueObject('related', $related);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->relations->set('related', $related);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSuperParent(LinkParent $superParent): self
|
||||
public function setSuperParent(LinkParent|Entity $superParent): self
|
||||
{
|
||||
$this->set('superParentId', $superParent->getId());
|
||||
$this->set('superParentType', $superParent->getEntityType());
|
||||
if ($superParent instanceof LinkParent) {
|
||||
$this->set('superParentId', $superParent->getId());
|
||||
$this->set('superParentType', $superParent->getEntityType());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->relations->set('superParent', $superParent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ class RelationsTest extends BaseTestCase
|
||||
$this->assertEquals($account->getId(), $lead2->get('createdAccountId'));
|
||||
|
||||
$em->refreshEntity($lead1);
|
||||
|
||||
|
||||
$this->assertEquals(null, $lead1->get('createdAccountId'));
|
||||
|
||||
$account->setRelatedOriginalLead(null);
|
||||
|
||||
Reference in New Issue
Block a user