Sulu\Bundle\ContactBundle\Entity\AccountInterface::setParent PHP Method

setParent() public method

Set parent.
public setParent ( Sulu\Bundle\ContactBundle\Entity\AccountInterface $parent = null ) : Account
$parent Sulu\Bundle\ContactBundle\Entity\AccountInterface
return Account
    public function setParent(AccountInterface $parent = null);

Usage Example

Example #1
0
 /**
  * Set parent to account.
  *
  * @param array $parentData
  * @param AccountInterface $account
  *
  * @throws \Sulu\Component\Rest\Exception\EntityNotFoundException
  */
 private function setParent($parentData, AccountInterface $account)
 {
     if ($parentData != null && isset($parentData['id']) && $parentData['id'] != 'null' && $parentData['id'] != '') {
         $parent = $this->getDoctrine()->getRepository($this->getAccountEntityName())->findAccountById($parentData['id']);
         if (!$parent) {
             throw new EntityNotFoundException($this->getAccountEntityName(), $parentData['id']);
         }
         $account->setParent($parent);
     } else {
         $account->setParent(null);
     }
 }