Converts an array of standard object instances to Comment model instances

@access protected
@param array $comments
@return array
358440
protected function convertAndReturn($comments)
    {
        // Create the return value
        $retval = false;
        if ($comments && is_array($comments) && count($comments)) {
            // Create the array
            $retval = array();
            foreach ($comments as $theComment) {
                // Create a new instance
                $commentInstance = new $this->className($theComment);
                // Append the instance to the return value
                array_push($retval, $commentInstance);
            }
        }
        return $retval;
    }
41303
protected function extractPayload($model, $comments = '')
    {
        $payload = [];
        preg_match('/@payload\ (.*)\n/i', $comments, $doc);
        $isArray = false;
        if (count($doc)) {
            $namespace = str_replace('{__API__}', $model, $doc[1]);
            if (false !== strpos($namespace, '[') && false !== strpos($namespace, ']')) {
                $namespace = str_replace(']', '', str_replace('[', '', $namespace));
                $isArray = true;
            }
            $payload = $this->extractModelFields($namespace);
            $reflector = new \ReflectionClass($namespace);
            $shortName = $reflector->getShortName();
        } else {
            $namespace = $model;
            $shortName = $model;
        }

        return [$namespace, $shortName, $payload, $isArray];
    }
1226526
def comments=(comment_array)
      @comments = comment_array.map { |obj| obj = Logan::Comment.new obj if obj.is_a?(Hash) }
    end
97196
public function setAddComments(array $addComments = [])
    {
        /**
         * If array is type array("author:john Doe","Release:1",)
         */
        $comments = [];
        foreach ($addComments as $index => $value) {
            if (is_numeric($index) && mb_strpos($value, ':') > 0) {
                list($tag, $val) = explode(':', $value);
                $comments[$tag] = $val;
            } else {
                $comments[$index] = $value;
            }
        }
        return $this->setOptionValue(self::ADD_COMMENTS, $comments);
    }
1100385
public function setComments($comments)
    {
        foreach ($comments as $comment) {
            $comment->setPortfolio($this);
        }

        $this->comments = $comments;

        return $this;
    }
423752
protected function JoinCategory(&$Comments) {
      $DiscussionIDs = array();
      
      foreach ($Comments as &$Comment)
         $DiscussionIDs[$Comment['DiscussionID']] = TRUE;
      $DiscussionIDs = array_keys($DiscussionIDs);
      
      $Discussions = Gdn::SQL()->Select('d.*')
         ->From('Discussion d')
         ->WhereIn('DiscussionID', $DiscussionIDs)
         ->Get()->Result(DATASET_TYPE_ARRAY);
      
      $DiscussionsByID = array();
      foreach ($Discussions as $Discussion)
         $DiscussionsByID[$Discussion['DiscussionID']] = $Discussion;
      unset($$Discussions);
      
      foreach ($Comments as &$Comment) {
         $Comment['Discussion'] = $DiscussionsByID[$Comment['DiscussionID']];
         $Comment['CategoryID'] = GetValueR('Discussion.CategoryID', $Comment);
      }
   }
850943
public function show(string $comment, array $params = [])
    {
        $path = $this->buildCommentsPath($comment);

        return $this->get($path, $params);
    }
636678
public function Comment($Comment) {
      $Comment['InsertUserID'] = Gdn::Session()->UserID;
      $Comment['DateInserted'] = Gdn_Format::ToDateTime();
      $Comment['InsertIPAddress'] = Gdn::Request()->IpAddress();
      
      $this->Validation->ApplyRule('ActivityID', 'Required');
      $this->Validation->ApplyRule('Body', 'Required');
      $this->Validation->ApplyRule('DateInserted', 'Required');
      $this->Validation->ApplyRule('InsertUserID', 'Required');
      
      $this->EventArguments['Comment'] = $Comment;
      $this->FireEvent('BeforeSaveComment');
      
      if ($this->Validate($Comment)) {
         $Activity = $this->GetID($Comment['ActivityID'], DATASET_TYPE_ARRAY);
         Gdn::Controller()->Json('Activity', $CommentActivityID);
         
         $_ActivityID = $Comment['ActivityID'];
         // Check to see if this is a shared activity/notification.
         if ($CommentActivityID = GetValue('CommentActivityID', $Activity['Data'])) {
            Gdn::Controller()->Json('CommentActivityID', $CommentActivityID);
            $Comment['ActivityID'] = $CommentActivityID;
         }
         
         // Check for spam.
         $Spam = SpamModel::IsSpam('ActivityComment', $Comment);
         if ($Spam)
            return SPAM;
         
         // Check for approval
         $ApprovalRequired = CheckRestriction('Vanilla.Approval.Require');
         if ($ApprovalRequired && !GetValue('Verified', Gdn::Session()->User)) {
         	LogModel::Insert('Pending', 'ActivityComment', $Comment);
         	return UNAPPROVED;
         }
         
         $ID = $this->SQL->Insert('ActivityComment', $Comment);
         
         if ($ID) {
            // Check to see if this comment bumps the activity.
            if ($Activity && GetValue('Bump', $Activity['Data'])) {
               $this->SQL->Put('Activity', array('DateUpdated' => $Comment['DateInserted']), array('ActivityID' => $Activity['ActivityID']));
               if ($_ActivityID != $Comment['ActivityID']) {
                  $this->SQL->Put('Activity', array('DateUpdated' => $Comment['DateInserted']), array('ActivityID' => $_ActivityID));
               }
            }
         }
         
         return $ID;
      }
      return FALSE;
   }
1297269
protected function recordDoc(array $comments)
    {
        $callable = $this->phpdocFactory;

        foreach ($comments as $comment) {
            if ($comment instanceof Doc) {
                $this->doc[] = $callable($comment->getText(), $this->context);
            }
        }
    }
1092646
protected function getDefaultAttributes($discussion)
    {
        if (! ($discussion instanceof Discussion)) {
            throw new InvalidArgumentException(
                get_class($this).' can only serialize instances of '.Discussion::class
            );
        }

        return [
            'title' => $discussion->title,
            'slug'  => $discussion->slug,
        ];
    }
1153400
public function setComment($comment): self
    {
        if (!empty($comment)) {
            if (is_array($comment)) {
                $this->docComment->setLines($comment);
            } elseif (is_string($comment)) {
                $this->docComment->setString($comment);
            }
        }

        return $this;
    }
1084355
public function addComment(\Innova\CollecticielBundle\Entity\CommentRead $comments)
    {
        $this->comments[] = $comments;

        return $this;
    }
731658
public function setComments($comments)
    {
        $this->comments = [];
        if (!is_array($comments)) {
            $comments = [$comments];
        }
        foreach ($comments as $comment) {
            $this->addComment($comment);
        }

        return $this;
    }
1058323
public function addComment($comment)
	{
		if(Yii::app()->params['commentNeedApproval'])
			$comment->status=Comment::STATUS_PENDING;
		else
			$comment->status=Comment::STATUS_APPROVED;
		$comment->post_id=$this->id;
		return $comment->save();
	}
82393
protected function extractTypeHintFromComment($comment)
    {
        if (empty($comment)) {
            return [null, null];
        }

        if (!preg_match('(\(DC2Type:(\w+)\))', $comment, $match)) {
            return [null, $comment];
        }

        $type    = $match[1];
        $comment = trim(str_replace('(DC2Type:' . $type . ')', '', $comment));

        if ($comment == '') {
            $comment = null;
        }

        return [$type, $comment];
    }
1023025
public static function extractVarType($comments = '')
    {
        $type = 'string';
        preg_match('/@var\ (.*) (.*)\n/i', $comments, $varType);
        if (count($varType)) {
            $aux = trim($varType[1]);
            $type = str_replace(' ', '', strlen($aux) > 0 ? $varType[1] : $varType[2]);
        }

        return $type;
    }
440313
public function comments(array $arguments = [])
    {
        $parameters = array_merge($arguments, [
            'post_id' => $this->id,
        ]);

        return $this->model->getComments($parameters);
    }