Name.php in User restrictions 8
File
src/Plugin/UserRestrictionType/Name.php
View source
<?php
namespace Drupal\user_restrictions\Plugin\UserRestrictionType;
class Name extends UserRestrictionTypeBase {
protected $name = '';
public function matches(array $data) {
if (!isset($data['name'])) {
return FALSE;
}
$this->name = $data['name'];
$restriction = parent::matchesValue($this->name);
if ($restriction) {
$this->logger
->notice('Restricted name %name matching %restriction has been blocked.', [
'%name' => $this->name,
'%restriction' => $restriction
->toLink($restriction
->label(), 'edit-form'),
]);
}
return $restriction;
}
public function getErrorMessage() {
return $this
->t('The name %name is reserved, and cannot be used.', [
'%name' => $this->name,
]);
}
}
Classes
Name |
Description |
Name |
Defines a restriction type by username. |