/**
* 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);
}
}