/** * Create a new update proposal from user form * * @param ActivityModel $oldActivity * @param array $params * @param type $dutch * @param type $english * @return ActivityProposalModel */ public function createUpdateProposal(ActivityModel $oldActivity, array $params, $dutch, $english) { if (!$this->isAllowed('update', 'activity')) { $translator = $this->getTranslator(); throw new \User\Permissions\NotAllowedException($translator->translate('You are not allowed to update an activity')); } $em = $this->getServiceManager()->get('Doctrine\\ORM\\EntityManager'); // Find the creator $user = $em->merge($this->getServiceManager()->get('user_role')); $newActivity = $this->generateActivity($params, $user, $oldActivity->getOrgan(), $dutch, $english, ActivityModel::STATUS_UPDATE); $proposal = new \Activity\Model\ActivityUpdateProposal(); $proposal->setOld($oldActivity); $proposal->setNew($newActivity); $em->persist($proposal); $em->flush(); return $proposal; }