Example #1
0
 /**
  * @param CheckpointInterface|string $checkpoint
  * @param string $context
  *
  * @return ActivationCheckpoint|ThrottleCheckpoint|CheckpointInterface
  */
 private function makeCheckpoint($checkpoint, $context)
 {
     switch ($checkpoint) {
         case ThrottleCheckpoint::class:
             return new ThrottleCheckpoint($this->repositories->createThrottleRepository($context), $this->container->make('request')->getClientIp());
         case ActivationCheckpoint::class:
             return new ActivationCheckpoint($this->repositories->createActivationRepository($context));
         default:
             return $this->container->make($checkpoint);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function createThrottleRepository($context)
 {
     if ($this->configuration($context)->getThrottleRepository()) {
         $repository = $this->container->make($this->configuration($context)->getThrottleRepository());
     } else {
         $repository = $this->defaults->createThrottleRepository($context);
     }
     /** @var ThrottleRepository $repository */
     $repository->setGlobalInterval($this->configuration($context)->getGlobalThrottleInterval());
     $repository->setGlobalThresholds($this->configuration($context)->getGlobalThrottleThresholds());
     $repository->setIpInterval($this->configuration($context)->getIpThrottleInterval());
     $repository->setIpThresholds($this->configuration($context)->getIpThrottleThresholds());
     $repository->setUserInterval($this->configuration($context)->getUserThrottleInterval());
     $repository->setUserThresholds($this->configuration($context)->getUserThrottleThresholds());
     return $repository;
 }
 /**
  * {@inheritdoc}
  */
 public function createThrottleRepository($context)
 {
     return $this->bindAndReturn(ThrottleRepository::class, $this->repositories->createThrottleRepository($context));
 }