You are here

public function RateLimit::__construct in RESTful 7.2

1 call to RateLimit::__construct()
RateLimitGlobal::__construct in src/Plugin/rate_limit/RateLimitGlobal.php
1 method overrides RateLimit::__construct()
RateLimitGlobal::__construct in src/Plugin/rate_limit/RateLimitGlobal.php

File

src/Plugin/rate_limit/RateLimit.php, line 40
Contains \Drupal\restful\Plugin\rate_limit\RateLimit

Class

RateLimit

Namespace

Drupal\restful\Plugin\rate_limit

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition) {
  parent::__construct($configuration, $plugin_id, $plugin_definition);
  try {
    $this->period = new \DateInterval($configuration['period']);
  } catch (\Exception $e) {
    throw new ServerConfigurationException(sprintf('Invalid rate limit period: %s. Should be a valid format of \\DateInterval.', $configuration['period']));
  }
  $this->limits = $configuration['limits'];
  $this->resource = $configuration['resource'];
}