function CoreServiceProvider::alter

Same name in other branches
  1. 9 core/lib/Drupal/Core/CoreServiceProvider.php \Drupal\Core\CoreServiceProvider::alter()
  2. 8.9.x core/lib/Drupal/Core/CoreServiceProvider.php \Drupal\Core\CoreServiceProvider::alter()
  3. 11.x 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 120

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');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.