protected function Uuid::determinePlugin

Determines the optimal implementation to use for generating UUIDs.

The selection is made based on the enabled PHP extensions with the most performant available option chosen.

Return value

string The class name for the optimal UUID generator.

1 call to Uuid::determinePlugin()
Uuid::__construct in drupal/core/lib/Drupal/Component/Uuid/Uuid.php
Instantiates the correct UUID object.

File

drupal/core/lib/Drupal/Component/Uuid/Uuid.php, line 67
Definition of Drupal\Component\Uuid\Uuid.

Class

Uuid
Factory class for UUIDs.

Namespace

Drupal\Component\Uuid

Code

protected function determinePlugin() {
  static $plugin;
  if (!empty($plugin)) {
    return $plugin;
  }
  $plugin = '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')) {
    $plugin = 'Drupal\\Component\\Uuid\\Pecl';
  }
  elseif (function_exists('com_create_guid')) {
    $plugin = 'Drupal\\Component\\Uuid\\Com';
  }
  return $plugin;
}