Exemplo n.º 1
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 CommunityEventComment();
     $comment->setMemberId($this->member->getId());
     $comment->setCommunityEventId($request['community_event_id']);
     $this->forward400If(false === $comment->getCommunityEvent()->isCreatableCommunityEventComment($this->member->getId()), 'you are not allowed to create comments on this event');
     $comment->setBody($request['body']);
     $comment->save();
     $this->comment = $comment;
 }
  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);
      $eventIds = $this->getEventIds($communityId);
      $memberIds = $this->getMemberIds($communityId);
      for ($j=0; $j < $options['eventnumber']; ++$j)
      {
        // イベントコメント
        for ($k=0; $k < $options['number']; ++$k)
        {
          $ctc = new CommunityEventComment();
          $ctc->setMemberId(self::fetchRandomMemberId($memberIds));
          $ctc->setCommunityEventId(self::fetchRandomEventId($eventIds));
          $ctc->setBody('body');
          $ctc->save();
          $ctc->free();
          $this->logSection('created a community event comment', sprintf("%s", $communityId));
        }
        // イベント参加メンバー
        for ($k=0; $k < $options['member']; ++$k)
        {
          $ctm = new CommunityEventMember();
          $ctm->setMemberId(self::fetchRandomMemberId($memberIds));
          $ctm->setCommunityEventId(self::fetchRandomEventId($eventIds));
          $ctm->save();
          $ctm->free();
          $this->logSection('created a community event member', sprintf("%s", $communityId));
        }
      }
    }
  }