Example #1
0
 protected static function fromStdClass($obj)
 {
     $ret = new self($obj->eventid);
     $ret->setTitle($obj->title);
     $ret->setDescripion($obj->desc);
     $ret->setFrom(\DateTime::createFromFormat('Y-m-d H:i:s', $obj->from, new \DateTimeZone("UTC")));
     $ret->setTo(\DateTime::createFromFormat('Y-m-d H:i:s', $obj->to, new \DateTimeZone("UTC")));
     $ret->getFrom()->setTimezone(new \DateTimeZone(get_option('timezone_string')));
     $ret->getTo()->setTimezone(new \DateTimeZone(get_option('timezone_string')));
     $ret->setPlace(Place::findById($obj->placeid));
     $ret->setPostId($obj->postid);
     return $ret;
 }
Example #2
0
 /**
  * @param PostId $postId
  * @param string $author
  * @param string $content
  * @return Comment
  */
 public static function create(PostId $postId, $author, $content)
 {
     $comment = new self($commentId = CommentId::generate());
     $comment->setPostId($postId);
     $comment->setAuthor($author);
     $comment->setContent($content);
     $comment->setCreatingDate($creatingDate = new \DateTime());
     $comment->recordThat(new CommentWasAdded($commentId, $postId, $author, $content, $creatingDate));
     return $comment;
 }