$context = PolicyController::getDefaultContext(); $counter = $this->getCounterForPeriod('per_second'); if ($counter->getThreshold() > 0 || $counter->getWarning() > 0) { $context->setRateLimitPerSecond($counter); } $counter = $this->getCounterForPeriod('per_minute'); if ($counter->getThreshold() > 0 || $counter->getWarning() > 0) { $context->setRateLimitPerMinute($counter); } $counter = $this->getCounterForPeriod('per_day'); if ($counter->getThreshold() > 0 || $counter->getWarning() > 0) { $context->setQuotaPerDay($counter); } $counter = $this->getCounterForPeriod('per_week'); if ($counter->getThreshold() > 0 || $counter->getWarning() > 0) { $context->setQuotaPerWeek($counter); } $counter = $this->getCounterForPeriod('per_month');