You are here

public function CoreServiceProvider::alter in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/CoreServiceProvider.php \Drupal\Core\CoreServiceProvider::alter()

Alters the UUID service to use the most efficient method available.

Parameters

\Drupal\Core\DependencyInjection\ContainerBuilder $container: The container builder.

Overrides ServiceModifierInterface::alter

File

core/lib/Drupal/Core/CoreServiceProvider.php, line 108

Class

CoreServiceProvider
ServiceProvider class for mandatory core services.

Namespace

Drupal\Core

Code

public function alter(ContainerBuilder $container) {
  $uuid_service = $container
    ->getDefinition('uuid');

  // Debian/Ubuntu uses the (broken) OSSP extension as their UUID
  // implementation. The OSSP implementation is not compatible with the
  // PECL functions.
  if (function_exists('uuid_create') && !function_exists('uuid_make')) {
    $uuid_service
      ->setClass('Drupal\\Component\\Uuid\\Pecl');
  }
  elseif (function_exists('com_create_guid')) {
    $uuid_service
      ->setClass('Drupal\\Component\\Uuid\\Com');
  }
}