public static function CoreServiceProvider::registerUuid

public static CoreServiceProvider::registerUuid(ContainerBuilder $container)

Determines and registers the UUID service.

Parameters

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

Return value

string Class name for the UUID service.

File

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

Class

CoreServiceProvider
ServiceProvider class for mandatory core services.

Namespace

Drupal\Core

Code

public static function registerUuid(ContainerBuilder $container) {
  $uuid_class = 'Drupal\Component\Uuid\Php';

  // 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_class = 'Drupal\Component\Uuid\Pecl';
  }
  // Try to use the COM implementation for Windows users.
  elseif (function_exists('com_create_guid')) {
    $uuid_class = 'Drupal\Component\Uuid\Com';
  }

  $container->register('uuid', $uuid_class);
  return $uuid_class;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!CoreServiceProvider.php/function/CoreServiceProvider::registerUuid/8.1.x