ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 10333


Ignore:
Timestamp:
Jan 23, 2009, 1:45:33 PM (11 years ago)
Author:
ebihara
Message:

#3111:unified opAPI*::createEntryBy*() to opAPI::createEntryByInstance()

Location:
OpenPNE3/plugins/opWebAPIPlugin/trunk/lib/api
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opWebAPIPlugin/trunk/lib/api/opAPI.class.php

    r10332 r10333  
    6464    return md5(get_class($entry).$entry->getId());
    6565  }
     66
     67  protected function createEntryByInstance(BaseObject $obj, SimpleXMLElement $entry = null)
     68  {
     69    $entry = new opAtomPubDocumentEntry($entry);
     70    $entry->setId($this->generateEntryId($obj));
     71    $entry->setPublished($obj->getCreatedAt());
     72    $entry->setUpdated($obj->getUpdatedAt());
     73
     74    return $entry;
     75  }
    6676}
  • OpenPNE3/plugins/opWebAPIPlugin/trunk/lib/api/opAPICommunityTopic.class.php

    r10332 r10333  
    3838    {
    3939      $entry = $feed->addEntry();
    40       $this->createEntryByTopic($topic, $entry);
     40      $this->createEntryByInstance($topic, $entry);
    4141    }
    4242    $feed->setUpdated($communityTopic[0]->getCreatedAt());
     
    4949    $id = $this->getRequiredParameter('id');
    5050    $topic = CommunityTopicPeer::retrieveByPk($id);
    51     $entry = $this->createEntryByTopic($topic);
     51    $entry = $this->createEntryByInstance($topic);
    5252    return $entry->publish();
    5353  }
     
    7171    $topic->save();
    7272
    73     $responseEntry = $this->createEntryByTopic($topic);
     73    $responseEntry = $this->createEntryByInstance($topic);
    7474    return $responseEntry->publish();
    7575  }
     
    9191    $topic->save();
    9292
    93     $responseEntry = $this->createEntryByTopic($topic);
     93    $responseEntry = $this->createEntryByInstance($topic);
    9494    return $responseEntry->publish();
    9595  }
     
    108108  }
    109109
    110   protected function createEntryByTopic(CommunityTopic $topic, SimpleXMLElement $entry = null)
     110  protected function createEntryByInstance(BaseObject $topic, SimpleXMLElement $entry = null)
    111111  {
     112    $entry = parent::createEntryByInstance($topic, $entry);
    112113    sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url', 'opUtil'));
    113 
    114     $member = $topic->getMember();
    115     $mailAddress = $member->getConfig('pc_address');
    116     if (!$mailAddress)
    117     {
    118       $mailAddress = $member->getConfig('mobile_address');
    119     }
    120 
    121     $entry = new opAtomPubDocumentEntry($entry);
    122114    $entry->setTitle($topic->getName());
    123     $entry->setId($this->generateEntryId($topic));
    124     $entry->setAuthor($topic->getName(), $mailAddress);
    125     $entry->setPublished($topic->getCreatedAt());
    126     $entry->setUpdated($topic->getUpdatedAt());
     115    $entry->setAuthorByMember($topic->getMember());
    127116    $entry->setLink(app_url_for('pc_frontend', 'communityTopic/detail?id='.$topic->getId(), true), 'self', 'alternate');
    128117
  • OpenPNE3/plugins/opWebAPIPlugin/trunk/lib/api/opAPICommunityTopicComment.class.php

    r10332 r10333  
    3838    {
    3939      $entry = $feed->addEntry();
    40       $this->createEntryByTopicComment($comment, $entry);
     40      $this->createEntryByInstance($comment, $entry);
    4141    }
    4242    $feed->setUpdated($communityTopicComment[0]->getCreatedAt());
     
    4949    $id = $this->getRequiredParameter('id');
    5050    $comment = CommunityTopicCommentPeer::retrieveByPk($id);
    51     $entry = $this->createEntryByTopicComment($comment);
     51    $entry = $this->createEntryByInstance($comment);
    5252    return $entry->publish();
    5353  }
     
    7171    $comment->save();
    7272
    73     $responseEntry = $this->createEntryByTopicComment($comment);
     73    $responseEntry = $this->createEntryByInstance($comment);
    7474    return $responseEntry->publish();
    7575  }
     
    9191    $comment->save();
    9292
    93     $responseEntry = $this->createEntryByTopicComment($comment);
     93    $responseEntry = $this->createEntryByInstance($comment);
    9494    return $responseEntry->publish();
    9595  }
     
    108108  }
    109109
    110   protected function createEntryByTopicComment(CommunityTopicComment $comment, SimpleXMLElement $entry = null)
     110  protected function createEntryByInstance(BaseObject $comment, SimpleXMLElement $entry = null)
    111111  {
     112    $entry = parent::createEntryByInstance($comment, $entry);
    112113    sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url', 'opUtil'));
    113 
    114     $member = $comment->getMember();
    115     $mailAddress = $member->getConfig('pc_address');
    116     if (!$mailAddress)
    117     {
    118       $mailAddress = $member->getConfig('mobile_address');
    119     }
    120 
    121     $entry = new opAtomPubDocumentEntry($entry);
    122114    $entry->setTitle($comment->getCommunityTopic()->getName());
    123115    $entry->setContent($comment->getBody());
    124     $entry->setId($this->generateEntryId($comment));
    125     $entry->setAuthor($member->getName(), $mailAddress);
    126     $entry->setPublished($comment->getCreatedAt());
    127     $entry->setUpdated($comment->getUpdatedAt());
     116    $entry->setAuthorByMember($comment->getMember());
    128117    $entry->setLink(app_url_for('pc_frontend', 'communityTopic/detail?id='.$comment->getCommunityTopic()->getId(), true), 'self', 'alternate');
    129118
  • OpenPNE3/plugins/opWebAPIPlugin/trunk/lib/api/opAPIDiary.class.php

    r10332 r10333  
    3838    {
    3939      $entry = $feed->addEntry();
    40       $this->createEntryByDiary($diary, $entry);
     40      $this->createEntryByInstance($diary, $entry);
    4141    }
    4242    $feed->setUpdated($result[0]->getCreatedAt());
     
    4949    $id = $this->getRequiredParameter('id');
    5050    $diary = DiaryPeer::retrieveByPk($id);
    51     $entry = $this->createEntryByDiary($diary);
     51    $entry = $this->createEntryByInstance($diary);
    5252    return $entry->publish();
    5353  }
     
    6868    $diary->save();
    6969
    70     $responseEntry = $this->createEntryByDiary($diary);
     70    $responseEntry = $this->createEntryByInstance($diary);
    7171    return $responseEntry->publish();
    7272  }
     
    8989    $diary->save();
    9090
    91     $responseEntry = $this->createEntryByDiary($diary);
     91    $responseEntry = $this->createEntryByInstance($diary);
    9292    return $responseEntry->publish();
    9393  }
     
    106106  }
    107107
    108   protected function createEntryByDiary(Diary $diary, SimpleXMLElement $entry = null)
     108  protected function createEntryByInstance(BaseObject $diary, SimpleXMLElement $entry = null)
    109109  {
     110    $entry = parent::createEntryByInstance($diary, $entry);
    110111    sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url', 'opUtil'));
    111 
    112     $member = $diary->getMember();
    113     $mailAddress = $member->getConfig('pc_address');
    114     if (!$mailAddress)
    115     {
    116       $mailAddress = $member->getConfig('mobile_address');
    117     }
    118 
    119     $entry = new opAtomPubDocumentEntry($entry);
    120112    $entry->setTitle($diary->getTitle());
    121113    $entry->setContent($diary->getBody());
    122     $entry->setId($this->generateEntryId($diary));
    123     $entry->setAuthor($member->getName(), $mailAddress);
    124     $entry->setPublished($diary->getCreatedAt());
    125     $entry->setUpdated($diary->getUpdatedAt());
     114    $entry->setAuthorByMember($diary->getMember());
    126115    $entry->setLink(app_url_for('pc_frontend', '@diary_show?id='.$diary->getId(), true), 'self', 'alternate');
    127116    $entry->setLink(app_url_for('mobile_frontend', '@diary_show?id='.$diary->getId(), true), 'self', 'alternate');
  • OpenPNE3/plugins/opWebAPIPlugin/trunk/lib/api/opAtomPubDocumentEntry.class.php

    r10331 r10333  
    7777  }
    7878
     79  public function setAuthorByMember(Member $member)
     80  {
     81    $mailAddress = $member->getConfig('pc_address');
     82    if (!$mailAddress)
     83    {
     84      $mailAddress = $member->getConfig('mobile_address');
     85    }
     86    $this->setAuthor($member->getName(), $mailAddress);
     87  }
     88
    7989  public function setPublished($published)
    8090  {
Note: See TracChangeset for help on using the changeset viewer.