class RestfulRateLimitGlobal in RESTful 7
@file Contains RestfulRateLimitGlobal
Hierarchy
- class \RestfulRateLimitBase implements RestfulRateLimitInterface
- class \RestfulRateLimitGlobal
Expanded class hierarchy of RestfulRateLimitGlobal
1 string reference to 'RestfulRateLimitGlobal'
- global.inc in plugins/
rate_limit/ global.inc
File
- plugins/
rate_limit/ RestfulRateLimitGlobal.class.php, line 8 - Contains RestfulRateLimitGlobal
View source
class RestfulRateLimitGlobal extends \RestfulRateLimitBase {
/**
* {@inheritdoc}
*/
public function __construct(array $plugin_info, $resource = NULL) {
parent::__construct($plugin_info, $resource);
$limit = variable_get('restful_global_rate_limit', 0);
foreach (user_roles() as $rid => $role_info) {
$this->limits[$rid] = $limit;
}
$this->period = new \DateInterval(variable_get('restful_global_rate_period', 'P1D'));
}
/**
* {@inheritdoc}
*/
public function generateIdentifier(\stdClass $account = NULL) {
$identifier = '';
$identifier .= $this->name . '::';
$identifier .= empty($account->uid) ? ip_address() : $account->uid;
return $identifier;
}
/**
* {@inheritdoc}
*
* All limits are the same for the global limit. Return the first one.
*/
public function getLimit(\stdClass $account = NULL) {
return reset($this->limits);
}
/**
* {@inheritdoc}
*
* Only track the global limit for the current user if the variable is on.
*/
public function isRequestedEvent(array $request = array()) {
return $this
->getLimit() > 0;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RestfulRateLimitBase:: |
protected | property | Array of maximum limit of requests across all endpoints per role. | |
RestfulRateLimitBase:: |
protected | property | The event name. | |
RestfulRateLimitBase:: |
protected | property | Period after which the rate limit is expired. | |
RestfulRateLimitBase:: |
protected | property | The resource name this object is limiting access to. | |
RestfulRateLimitBase:: |
public | function | Get the rate limit period. | |
RestfulRateLimitBase:: |
public | function | Load rate limit entity. | |
RestfulRateLimitBase:: |
public | function | Set the rate limit. | |
RestfulRateLimitBase:: |
public | function | Set the rate limit period. | |
RestfulRateLimitGlobal:: |
public | function |
Generates an identifier for the event and the request. Overrides RestfulRateLimitBase:: |
|
RestfulRateLimitGlobal:: |
public | function |
All limits are the same for the global limit. Return the first one. Overrides RestfulRateLimitBase:: |
|
RestfulRateLimitGlobal:: |
public | function |
Only track the global limit for the current user if the variable is on. Overrides RestfulRateLimitInterface:: |
|
RestfulRateLimitGlobal:: |
public | function |
Constructor. Overrides RestfulRateLimitBase:: |