class RateLimit in RESTful 7.2
Same name in this branch
- 7.2 src/Annotation/RateLimit.php \Drupal\restful\Annotation\RateLimit
- 7.2 src/RateLimit/Entity/RateLimit.php \Drupal\restful\RateLimit\Entity\RateLimit
- 7.2 src/Plugin/rate_limit/RateLimit.php \Drupal\restful\Plugin\rate_limit\RateLimit
Hierarchy
- class \Drupal\restful\RateLimit\Entity\RateLimit extends \Drupal\restful\RateLimit\Entity\Entity
Expanded class hierarchy of RateLimit
File
- src/
RateLimit/ Entity/ RateLimit.php, line 10 - Contains Drupal\restful\RateLimit\Entity\RateLimit.
Namespace
Drupal\restful\RateLimit\EntityView source
class RateLimit extends \Entity {
/**
* Number of hits.
*
* @var int
*/
public $hits = 0;
/**
* Expiration timestamp.
*
* @var int
*/
public $expiration = 0;
/**
* Saves an extra hit.
*/
public function hit() {
$this->hits++;
$this
->save();
}
/**
* Checks if the entity is expired.
*/
public function isExpired() {
return REQUEST_TIME > $this->expiration;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RateLimit:: |
public | property | Expiration timestamp. | |
RateLimit:: |
public | property | Number of hits. | |
RateLimit:: |
public | function | Saves an extra hit. | |
RateLimit:: |
public | function | Checks if the entity is expired. |