class RestrictByIpServiceProvider in Restrict Login or Role Access by IP Address 8.4
Rename current_user service and replace with one provided by restrict_by_ip module.
Hierarchy
- class \Drupal\Core\DependencyInjection\ServiceProviderBase implements ServiceModifierInterface, ServiceProviderInterface
- class \Drupal\restrict_by_ip\RestrictByIpServiceProvider
Expanded class hierarchy of RestrictByIpServiceProvider
File
- src/
RestrictByIpServiceProvider.php, line 19 - Contains Drupal\restrict_by_ip\RestrictByIpServiceProvider
Namespace
Drupal\restrict_by_ipView source
class RestrictByIpServiceProvider extends ServiceProviderBase {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
// Rename current_user service.
$coreService = $container
->getDefinition('current_user');
$container
->setDefinition('restrict_by_ip.current_user', $coreService);
// Register this modules class as default for current_user service.
$newService = new Definition('Drupal\\restrict_by_ip\\Session\\AccountProxy');
$newService
->addArgument(new Reference('restrict_by_ip.current_user'));
$newService
->addArgument(new Reference('restrict_by_ip.role_firewall'));
$container
->setDefinition('current_user', $newService);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RestrictByIpServiceProvider:: |
public | function |
Modifies existing service definitions. Overrides ServiceProviderBase:: |
|
ServiceProviderBase:: |
public | function |
Registers services to the container. Overrides ServiceProviderInterface:: |
1 |