class RateLimitDecoratedResource in RESTful 7.2
Class RateLimitDecoratedResource.
@package Drupal\restful\Plugin\resource\Decorators
Hierarchy
- class \Drupal\restful\Plugin\resource\Decorators\ResourceDecoratorBase extends \Drupal\Component\Plugin\PluginBase implements ResourceDecoratorInterface, ExplorableDecoratorInterface
- class \Drupal\restful\Plugin\resource\Decorators\RateLimitDecoratedResource implements ResourceDecoratorInterface
Expanded class hierarchy of RateLimitDecoratedResource
1 file declares its use of RateLimitDecoratedResource
File
- src/
Plugin/ resource/ Decorators/ RateLimitDecoratedResource.php, line 18 - Contains \Drupal\restful\Plugin\resource\Decorators\RateLimitDecoratedResource
Namespace
Drupal\restful\Plugin\resource\DecoratorsView source
class RateLimitDecoratedResource extends ResourceDecoratorBase implements ResourceDecoratorInterface {
/**
* Authentication manager.
*
* @var RateLimitManager
*/
protected $rateLimitManager;
/**
* Constructs a Drupal\Component\Plugin\PluginBase object.
*
* @param ResourceInterface $subject
* The decorated object.
* @param RateLimitManager $rate_limit_manager
* Injected rate limit manager.
*/
public function __construct(ResourceInterface $subject, RateLimitManager $rate_limit_manager = NULL) {
$this->subject = $subject;
$plugin_definition = $subject
->getPluginDefinition();
$rate_limit_info = empty($plugin_definition['rateLimit']) ? array() : $plugin_definition['rateLimit'];
if ($limit = variable_get('restful_global_rate_limit', 0)) {
$rate_limit_info['global'] = array(
'period' => variable_get('restful_global_rate_period', 'P1D'),
'limits' => array(),
);
foreach (user_roles() as $role_name) {
$rate_limit_info['global']['limits'][$role_name] = $limit;
}
}
$this->rateLimitManager = $rate_limit_manager ? $rate_limit_manager : new RateLimitManager($this, $rate_limit_info);
}
/**
* Setter for $rateLimitManager.
*
* @param RateLimitManager $rate_limit_manager
* The rate limit manager.
*/
protected function setRateLimitManager(RateLimitManager $rate_limit_manager) {
$this->rateLimitManager = $rate_limit_manager;
}
/**
* Getter for $rate_limit_manager.
*
* @return RateLimitManager
* The rate limit manager.
*/
protected function getRateLimitManager() {
return $this->rateLimitManager;
}
/**
* {@inheritdoc}
*/
public function process() {
// This will throw the appropriate exception if needed.
$this
->getRateLimitManager()
->checkRateLimit($this
->getRequest());
return $this->subject
->process();
}
/**
* {@inheritdoc}
*/
public function setAccount($account) {
$this->subject
->setAccount($account);
$this->rateLimitManager
->setAccount($account);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RateLimitDecoratedResource:: |
protected | property | Authentication manager. | |
RateLimitDecoratedResource:: |
protected | function | Getter for $rate_limit_manager. | |
RateLimitDecoratedResource:: |
public | function |
Controller function that passes the data along and executes right action. Overrides ResourceDecoratorBase:: |
|
RateLimitDecoratedResource:: |
public | function |
Overrides ResourceDecoratorBase:: |
|
RateLimitDecoratedResource:: |
protected | function | Setter for $rateLimitManager. | |
RateLimitDecoratedResource:: |
public | function | Constructs a Drupal\Component\Plugin\PluginBase object. | |
ResourceDecoratorBase:: |
protected | property | The decorated resource. | |
ResourceDecoratorBase:: |
public | function |
Determine if user can access the handler. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function | ||
ResourceDecoratorBase:: |
public | function |
Gets the controllers. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Basic implementation for create. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Data provider factory. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function | ||
ResourceDecoratorBase:: |
public | function |
Disable the resource. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function |
Discovery controller callback. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Shorthand method to perform a quick DELETE request. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Shorthand method to perform a quick GET request. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Shorthand method to perform a quick PATCH request. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Shorthand method to perform a quick POST request. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Shorthand method to perform a quick PUT request. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
private | function | ||
ResourceDecoratorBase:: |
public | function |
Enable the resource. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function |
Get the user from for request. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function | ||
ResourceDecoratorBase:: |
public | function |
Return the controller for a given path. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Gets the controllers for this resource. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Gets the data provider. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function |
Gets the decorated resource. Overrides ResourceDecoratorInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Gets the field definitions. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function |
Gets the path of the resource. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function | This is a decorated resource, get proxy the request until you reach the annotated resource. | 1 |
ResourceDecoratorBase:: |
public | function | ||
ResourceDecoratorBase:: |
public | function |
Gets the primary resource, the one that is not a decorator. Overrides ResourceDecoratorInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Get the request object. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Gets the resource machine name. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function |
Gets the resource name. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Helper method; Get the URL of the resource and query strings. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Return array keyed with the major and minor version of the resource. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Basic implementation for listing. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function |
Checks if the resource is enabled. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function |
Checks if the decorated object is an instance of something. Overrides ExplorableDecoratorInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Basic implementation for update. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function |
Basic implementation for update. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function | ||
ResourceDecoratorBase:: |
public | function |
Sets the data provider. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function |
Sets the field definitions. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Sets the path of the resource. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function |
This is a decorated resource, set proxy the request until you reach the
annotated resource. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Sets the request object. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Switches the user back from the original user for the session. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Basic implementation for update. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function |
Gets a resource URL based on the current version. Overrides ResourceInterface:: |
|
ResourceDecoratorBase:: |
public | function |
Basic implementation for view. Overrides ResourceInterface:: |
1 |
ResourceDecoratorBase:: |
public | function | If any method not declared, then defer it to the decorated field. | |
ResourceInterface:: |
constant | The string that separates multiple ids. |