Comment::parent PHP Method

parent() public method

Return the parent comment, if applicable
public parent ( ) : Comment | null
return Comment | null
    public function parent()
    {
        if (!is_null($this->_parent)) {
            return $this->_parent;
        }
        $field = $this->getField();
        if (!$field->depth) {
            return null;
        }
        $parent_id = $this->parent_id;
        if (!$parent_id) {
            return null;
        }
        $comments = $this->getPage()->get($field->name);
        $parent = null;
        foreach ($comments as $c) {
            if ($c->id != $parent_id) {
                continue;
            }
            $parent = $c;
            break;
        }
        $this->_parent = $parent;
        return $parent;
    }