for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace sweelix\oauth2\server\commands;
use Yii;
use yii\console\Controller;
use yii\console\ExitCode;
class CronJobController extends Controller
{
/**
* @return int
* @throws \yii\db\Exception
*/
public function actionRemoveExpired()
$tokenSuppressedNumber = 0;
$tokenSuppressedNumber += Yii::$app->db->createCommand()
->delete('oauthAccessTokens', 'expiry <= NOW()')
->execute();
->delete('oauthAuthorizationCodes', 'expiry <= NOW()')
->delete('oauthJtis', 'expires <= NOW()')
->delete('oauthRefreshTokens', 'expiry <= NOW()')
$this->stdout($tokenSuppressedNumber."\n");
return ExitCode::OK;
}