/** * 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; }
/** * Revoke a proposed activity update * NB: This action permanently removes the proposal, so this cannot be undone. * (The potentially updated activity remains untouched) * * @param ActivityProposalModel $proposal */ public function revokeUpdateProposal(ActivityProposalModel $proposal) { $em = $this->getServiceManager()->get('Doctrine\\ORM\\EntityManager'); $new = $proposal->getNew(); $em->remove($proposal); $em->remove($new); $em->flush(); }