Habari\Comment::insert PHP Method

insert() public method

Saves a new comment to the comments table
public insert ( ) : integer | boolean
return integer | boolean The inserted record id on success, false if not
    public function insert()
    {
        $allow = true;
        $allow = Plugins::filter('comment_insert_allow', $allow, $this);
        if (!$allow) {
            return false;
        }
        Plugins::act('comment_insert_before', $this);
        // Invoke plugins for all fields, since they're all "changed" when inserted
        foreach ($this->fields as $fieldname => $value) {
            Plugins::act('comment_update_' . $fieldname, $this, $this->{$fieldname}, $value);
        }
        $result = parent::insertRecord(DB::table('comments'));
        $this->newfields['id'] = DB::last_insert_id();
        // Make sure the id is set in the comment object to match the row id
        $this->fields = array_merge($this->fields, $this->newfields);
        $this->newfields = array();
        $this->info->commit($this->fields['id']);
        Plugins::act('comment_insert_after', $this);
        return $result;
    }