protected function onAfterWrite() {
        parent::onAfterWrite();
        
        //Write the snippet version record
        if(!empty($this->Text)) {
            $version=new SnippetVersion();
            $version->Text=$this->Text;
            $version->ParentID=$this->ID;
            $version->write();
        }
    }