Commit 4c3b3764 authored by catch's avatar catch

Issue #2708379 by alexpott: Add uuid service to core.services.yml

parent 4376b33c
......@@ -1600,7 +1600,8 @@ services:
update.post_update_registry_factory:
class: Drupal\Core\Update\UpdateRegistryFactory
parent: container.trait
uuid:
class: Drupal\Component\Uuid\Php
response_filter.active_link:
class: Drupal\Core\EventSubscriber\ActiveLinkResponseFilter
arguments: ['@current_user', '@path.current', '@path.matcher', '@language_manager']
......
......@@ -15,6 +15,7 @@
use Drupal\Core\DependencyInjection\Compiler\StackedSessionHandlerPass;
use Drupal\Core\DependencyInjection\Compiler\RegisterStreamWrappersPass;
use Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\Compiler\ModifyServiceDefinitionsPass;
......@@ -39,13 +40,12 @@
*
* @ingroup container
*/
class CoreServiceProvider implements ServiceProviderInterface {
class CoreServiceProvider implements ServiceProviderInterface, ServiceModifierInterface {
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) {
$this->registerUuid($container);
$this->registerTest($container);
// Only register the private file stream wrapper if a file path has been set.
......@@ -98,30 +98,23 @@ public function register(ContainerBuilder $container) {
}
/**
* Determines and registers the UUID service.
* Alters the UUID service to use the most efficient method available.
*
* @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
* The container builder.
*
* @return string
* Class name for the UUID service.
*/
public static function registerUuid(ContainerBuilder $container) {
$uuid_class = 'Drupal\Component\Uuid\Php';
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_class = 'Drupal\Component\Uuid\Pecl';
$uuid_service->setClass('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';
$uuid_service->setClass('Drupal\Component\Uuid\Com');
}
$container->register('uuid', $uuid_class);
return $uuid_class;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment