code/model/KapostPreviewToken.php
protected function onAfterWrite() {
        parent::onAfterWrite();
        
        
        //Clean up the expired tokens
        $expiredTokens=KapostPreviewToken::get()->filter('Created:LessThan', date('Y-m-d H:i:s', strtotime('-'.KapostService::config()->preview_token_expiry.' minutes')));
        if($expiredTokens->count()>0) {
            foreach($expiredTokens as $token) {
                $token->delete();
            }
        }
    }
protected function onAfterWrite() {
        parent::onAfterWrite();
        
        
        //Clean up the expired tokens
        $expiredTokens=KapostPreviewToken::get()->filter('Created:LessThan', date('Y-m-d H:i:s', strtotime('-'.KapostService::config()->preview_token_expiry.' minutes')));
        if($expiredTokens->count()>0) {
            foreach($expiredTokens as $token) {
                $token->delete();
            }
        }
    }
protected function onAfterWrite ( ) { parent :: onAfterWrite ( ) ; //Clean up the expired tokens $ expiredTokens = KapostPreviewToken :: get ( ) -> filter ( 'Created:LessThan' , date ( 'Y-m-d H:i:s' , strtotime ( '-' . KapostService :: config ( ) -> preview_token_expiry . ' minutes' ) ) ) ; if ( $ expiredTokens -> count ( ) > 0 ) { foreach ( $ expiredTokens as $ token ) { $ token -> delete ( ) ; } } }
Cleans up the expired tokens after writing
Cleans up the expired tokens after writing