You are here

public function RateLimit::generateIdentifier in RESTful 7.2

Generates an identifier for the event and the request.

Parameters

object $account: The account object for the user making the request.

Return value

string The ID.

Overrides RateLimitInterface::generateIdentifier

1 method overrides RateLimit::generateIdentifier()
RateLimitGlobal::generateIdentifier in src/Plugin/rate_limit/RateLimitGlobal.php
Generates an identifier for the event and the request.

File

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

Class

RateLimit

Namespace

Drupal\restful\Plugin\rate_limit

Code

public function generateIdentifier($account = NULL) {
  $identifier = $this->resource
    ->getResourceName() . PluginBase::DERIVATIVE_SEPARATOR;
  if ($this
    ->getPluginId() == 'global') {

    // Don't split the id by resource if the event is global.
    $identifier = '';
  }
  $identifier .= $this
    ->getPluginId() . PluginBase::DERIVATIVE_SEPARATOR;
  $identifier .= empty($account->uid) ? ip_address() : $account->uid;
  return $identifier;
}