protected function executeTransaction($conn, $arguments = array(), $options = array()) { $communities = Doctrine::getTable('Community')->findAll(Doctrine::HYDRATE_ARRAY); foreach ($communities as $community) { for ($i = 0; $i < $options['number']; ++$i) { $ct = new CommunityTopic(); $ct->setCommunityId($community['id']); $ct->setMemberId(self::fetchRandomMemberId($community['id'])); $ct->setName('name'); $ct->setBody('body'); $ct->save(); $ct->free(); $this->logSection('created a community topic', sprintf("%s", $community['id'])); } } }
public function executePost(sfWebRequest $request) { try { $topicId = $request->getParameter('id'); $communityId = $request->getParameter('community_id'); $this->isValidNameAndBody($request->getParameter('name'), $request->getParameter('body')); if ($topicId) { $topic = $this->getTargetObject('topic', $topicId); } else { $this->forward400If(!$communityId, 'community_id parameter is not specified.'); $topic = new CommunityTopic(); $topic->setMemberId($this->member->getId()); $topic->setCommunityId($communityId); } $this->forward400If(!$this->isAllowed($topic->getCommunity(), $this->member, 'add'), 'you are not allowed to create or update topics on this community'); $topic->setName($request['name']); $topic->setBody($request['body']); $topic->save(); } catch (opCommunityTopicAPIRuntimeException $e) { $this->forward400($e->getMessage()); } $this->topic = $topic; }