/** * @param ObjectManager $manager * @param string $name * @param Account $parent * @param AccountGroup $group * @return Account */ protected function createAccount(ObjectManager $manager, $name, Account $parent = null, AccountGroup $group = null) { $account = new Account(); $account->setName($name); $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst(); $account->setOrganization($organization); if ($parent) { $account->setParent($parent); } if ($group) { $account->setGroup($group); } $manager->persist($account); $this->addReference($name, $account); return $account; }
/** * @ORM\PrePersist */ public function createAccount() { if (!$this->account) { $this->account = new Account(); $this->account->setOrganization($this->organization); $this->account->setName(sprintf('%s %s', $this->firstName, $this->lastName)); if ($this->getOwner() && !$this->account->getOwner()) { $this->account->setOwner($this->getOwner(), false); } } }