protected function execute($arguments = array(), $options = array())
  {
    $databaseManager = new sfDatabaseManager($this->configuration);
    $this->conn = $databaseManager->getDatabase('doctrine')->getDoctrineConnection();

    $communityIds = $this->getCommunityIds();
    for ($i=0; $i < $options['communitynumber']; ++$i)
    {
      $communityId = $this->fetchRandomCommunityId($communityIds);
      $topicIds = $this->getTopicIds($communityId);
      $memberIds = $this->getMemberIds($communityId);
      for ($j=0; $j < $options['topicnumber']; ++$j)
      {
        for ($k=0; $k < $options['number']; ++$k)
        {
          $ctc = new CommunityTopicComment();
          $ctc->setMemberId(self::fetchRandomMemberId($memberIds));
          $ctc->setCommunityTopicId(self::fetchRandomTopicId($topicIds));
          $ctc->setBody('body');
          $ctc->save();
          $ctc->free();
          $this->logSection('created a community topic comment', sprintf("%s", $communityId));
        }
      }
    }
  }
예제 #2
0
 public function executePost(sfWebRequest $request)
 {
     $this->forward400If('' === (string) $request['body'], 'body parameter is not specified.');
     if ($limit = sfConfig::get('app_smt_comment_post_limit')) {
         $this->forward400If(mb_strlen($request['body']) > $limit, 'body parameter is too long');
     }
     $comment = new CommunityTopicComment();
     $comment->setMemberId($this->member->getId());
     $comment->setCommunityTopicId($request['community_topic_id']);
     $this->forward400If(false === $comment->getCommunityTopic()->isCreatableCommunityTopicComment($this->member->getId()), 'you are not allowed to create comments on this topic');
     $comment->setBody($request['body']);
     $comment->save();
     $this->comment = $comment;
 }