Beispiel #1
0
 /**
  * Set and get a specific comment
  *
  * @return     void
  */
 public function comment($id = null)
 {
     if (!isset($this->_comment) || $id !== null && (int) $this->_comment->get('id') != $id) {
         $this->_comment = null;
         // See if we already have a list of comments that we can look through
         if ($this->_comments instanceof ItemList) {
             foreach ($this->_comments as $key => $comment) {
                 if ((int) $comment->get('id') == $id) {
                     $this->_comment = $comment;
                     break;
                 }
             }
         }
         // Nothing found so far?
         if (!$this->_comment) {
             // Load the record
             $this->_comment = Comment::getInstance($id);
         }
     }
     return $this->_comment;
 }