You are here

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

Expanded class hierarchy of RestrictByIpServiceProvider

File

src/RestrictByIpServiceProvider.php, line 19
Contains Drupal\restrict_by_ip\RestrictByIpServiceProvider

Namespace

Drupal\restrict_by_ip
View 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

Namesort descending Modifiers Type Description Overrides
RestrictByIpServiceProvider::alter public function Modifies existing service definitions. Overrides ServiceProviderBase::alter
ServiceProviderBase::register public function Registers services to the container. Overrides ServiceProviderInterface::register 1