public function purgeTokens(): void
    {
        /** @var OptInModel $adapter */
        $adapter = $this->framework->getAdapter(OptInModel::class);

        if (!$tokens = $adapter->findExpiredTokens()) {
            return;
        }

        /** @var Model $adapter */
        $adapter = $this->framework->getAdapter(Model::class);

        foreach ($tokens as $token) {
            $delete = true;
            $related = $token->getRelatedRecords();

            foreach ($related as $table => $id) {
                /** @var Model $model */
                $model = $this->framework->getAdapter($adapter->getClassFromTable($table));

                // Check if the related records still exist
                if (null !== $model->findMultipleByIds($id)) {
                    $delete = false;
                    break;
                }
            }

            if ($delete) {
                $token->delete();
            } else {
                // Prolong the token for another 3 years if the related records still exist
                $token->removeOn = strtotime('+3 years', (int) $token->removeOn);
                $token->save();
            }
        }
    }
public function purgeTokens(): void
    {
        
        $adapter = $this->framework->getAdapter(OptInModel::class);

        if (!$tokens = $adapter->findExpiredTokens()) {
            return;
        }

        
        $adapter = $this->framework->getAdapter(Model::class);

        foreach ($tokens as $token) {
            $delete = true;
            $related = $token->getRelatedRecords();

            foreach ($related as $table => $id) {
                
                $model = $this->framework->getAdapter($adapter->getClassFromTable($table));

                
                if (null !== $model->findMultipleByIds($id)) {
                    $delete = false;
                    break;
                }
            }

            if ($delete) {
                $token->delete();
            } else {
                
                $token->removeOn = strtotime('+3 years', (int) $token->removeOn);
                $token->save();
            }
        }
    }
public function purgeTokens ( ) : void { /** @var OptInModel $adapter */ $ adapter = $ this -> framework -> getAdapter ( OptInModel :: class ) ; if ( ! $ tokens = $ adapter -> findExpiredTokens ( ) ) { return ; } /** @var Model $adapter */ $ adapter = $ this -> framework -> getAdapter ( Model :: class ) ; foreach ( $ tokens as $ token ) { $ delete = true ; $ related = $ token -> getRelatedRecords ( ) ; foreach ( $ related as $ table => $ id ) { /** @var Model $model */ $ model = $ this -> framework -> getAdapter ( $ adapter -> getClassFromTable ( $ table ) ) ; // Check if the related records still exist if ( null !== $ model -> findMultipleByIds ( $ id ) ) { $ delete = false ; break ; } } if ( $ delete ) { $ token -> delete ( ) ; } else { // Prolong the token for another 3 years if the related records still exist $ token -> removeOn = strtotime ( '+3 years' , ( int ) $ token -> removeOn ) ; $ token -> save ( ) ; } } }
{@inheritdoc}
{