public function edit($params=array(), $form=null, $summaryoptions=array(), $attachmentoptions=array()) {
        global $CFG, $DB;

        $sitecontext = context_system::instance();
        $entry = $this;

        $this->form = $form;
        foreach ($params as $var => $val) {
            $entry->$var = $val;
        }

        $entry = file_postupdate_standard_editor($entry, 'summary', $summaryoptions, $sitecontext, 'blog', 'post', $entry->id);
        $entry = file_postupdate_standard_filemanager($entry,
                                                      'attachment',
                                                      $attachmentoptions,
                                                      $sitecontext,
                                                      'blog',
                                                      'attachment',
                                                      $entry->id);

        if (!empty($CFG->useblogassociations)) {
            $entry->add_associations();
        }

        $entry->lastmodified = time();

        // Update record.
        $DB->update_record('post', $entry);
        core_tag_tag::set_item_tags('core', 'post', $entry->id, context_user::instance($this->userid), $entry->tags);

        $event = \core\event\blog_entry_updated::create(array(
            'objectid'      => $entry->id,
            'relateduserid' => $entry->userid
        ));
        $event->set_blog_entry($entry);
        $event->trigger();
    }