Drupal 8  8.0.2
DatabaseBackend Class Reference
Inheritance diagram for DatabaseBackend:

Public Member Functions

 __construct (Connection $connection, RequestStack $request_stack)
 
 register ($name, $window=3600, $identifier=NULL)
 
 clear ($name, $identifier=NULL)
 
 isAllowed ($name, $threshold, $window=3600, $identifier=NULL)
 
 garbageCollection ()
 

Protected Attributes

 $connection
 
 $requestStack
 

Detailed Description

Defines the database flood backend. This is the default Drupal backend.

Constructor & Destructor Documentation

__construct ( Connection  $connection,
RequestStack  $request_stack 
)

Construct the DatabaseBackend.

Parameters
\Drupal\Core\Database\Connection$connectionThe database connection which will be used to store the flood event information.
\Symfony\Component\HttpFoundation\RequestStack$request_stackThe request stack used to retrieve the current request.

References Drupal\requestStack().

Here is the call graph for this function:

Member Function Documentation

clear (   $name,
  $identifier = NULL 
)

{Makes the flood control mechanism forget an event for the current visitor.

Parameters
string$nameThe name of an event.
string$identifier(optional) Unique identifier of the current user. Defaults to the current user's IP address).
}

Implements FloodInterface.

References Drupal\requestStack().

Here is the call graph for this function:

garbageCollection ( )

{Cleans up expired flood events. This method is called automatically on cron run.

See Also
system_cron()
}

Implements FloodInterface.

isAllowed (   $name,
  $threshold,
  $window = 3600,
  $identifier = NULL 
)

{Checks whether a user is allowed to proceed with the specified event.Events can have thresholds saying that each user can only do that event a certain number of times in a time window. This function verifies that the current user has not exceeded this threshold.

Parameters
string$nameThe name of an event.
int$thresholdThe maximum number of times each user can do this event per time window.
int$window(optional) Number of seconds in the time window for this event (default is 3600 seconds, or 1 hour).
string$identifier(optional) Unique identifier of the current user. Defaults to the current user's IP address).
Returns
TRUE if the user is allowed to proceed. FALSE if they have exceeded the threshold and should not be allowed to proceed.
}

Implements FloodInterface.

References Drupal\requestStack().

Here is the call graph for this function:

register (   $name,
  $window = 3600,
  $identifier = NULL 
)

{Registers an event for the current visitor to the flood control mechanism.

Parameters
string$nameThe name of an event. To prevent unintended name clashes, it is recommended to use the module name first in the event name, optionally followed by a dot and the actual event name (e.g. "mymodule.my_event").
int$window(optional) Number of seconds before this event expires. Defaults to 3600 (1 hour). Typically uses the same value as the isAllowed() $window parameter. Expired events are purged on cron run to prevent the flood table from growing indefinitely.
string$identifier(optional) Unique identifier of the current user. Defaults to the current user's IP address).
}

Implements FloodInterface.

References Drupal\requestStack().

Here is the call graph for this function:


The documentation for this class was generated from the following file: