public function ClientIp::matches in User restrictions 8
Check if the given data matches the restriction.
Parameters
array $data: Data to check.
Return value
bool TRUE if the value matches one of the restrictions, FALSE otherwise.
Overrides UserRestrictionTypeInterface::matches
File
- src/
Plugin/ UserRestrictionType/ ClientIp.php, line 46
Class
- ClientIp
- Defines a restriction type by client IP.
Namespace
Drupal\user_restrictions\Plugin\UserRestrictionTypeCode
public function matches(array $data) {
$client_ip = $this->requestStack
->getCurrentRequest()
->getClientIp();
$restriction = parent::matchesValue($client_ip);
if ($restriction) {
$this->logger
->notice('Restricted client IP %client_ip matching %restriction has been blocked.', [
'%client_ip' => $client_ip,
'%restriction' => $restriction
->toLink($restriction
->label(), 'edit-form'),
]);
}
return $restriction;
}