/** * Add Participant (add new Package and set participant) * * @param \Entity\User $participant * @return \Entity\Order */ public function addParticipant(Entity\User $participant) { $package = new Entity\Package(); $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $status = $em->getRepository('ErsBase\\Entity\\Status')->findOneBy(array('value' => 'order pending')); if (!$status) { throw new \Exception('Please setup status "order pending"'); } $package->setStatus($status); $status->addPackage($package); $package->setParticipant($participant); $this->getOrder()->addPackage($package); $package->setOrder($this->getOrder()); return $this->getOrder(); }