Issue #2708379 by alexpott: Add uuid service to core.services.yml
parent
4376b33cb3
commit
4c3b3764c2
|
@ -1600,7 +1600,8 @@ services:
|
||||||
update.post_update_registry_factory:
|
update.post_update_registry_factory:
|
||||||
class: Drupal\Core\Update\UpdateRegistryFactory
|
class: Drupal\Core\Update\UpdateRegistryFactory
|
||||||
parent: container.trait
|
parent: container.trait
|
||||||
|
uuid:
|
||||||
|
class: Drupal\Component\Uuid\Php
|
||||||
response_filter.active_link:
|
response_filter.active_link:
|
||||||
class: Drupal\Core\EventSubscriber\ActiveLinkResponseFilter
|
class: Drupal\Core\EventSubscriber\ActiveLinkResponseFilter
|
||||||
arguments: ['@current_user', '@path.current', '@path.matcher', '@language_manager']
|
arguments: ['@current_user', '@path.current', '@path.matcher', '@language_manager']
|
||||||
|
|
|
@ -15,6 +15,7 @@ use Drupal\Core\DependencyInjection\Compiler\StackedKernelPass;
|
||||||
use Drupal\Core\DependencyInjection\Compiler\StackedSessionHandlerPass;
|
use Drupal\Core\DependencyInjection\Compiler\StackedSessionHandlerPass;
|
||||||
use Drupal\Core\DependencyInjection\Compiler\RegisterStreamWrappersPass;
|
use Drupal\Core\DependencyInjection\Compiler\RegisterStreamWrappersPass;
|
||||||
use Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass;
|
use Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass;
|
||||||
|
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
|
||||||
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
|
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
|
||||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||||
use Drupal\Core\DependencyInjection\Compiler\ModifyServiceDefinitionsPass;
|
use Drupal\Core\DependencyInjection\Compiler\ModifyServiceDefinitionsPass;
|
||||||
|
@ -39,13 +40,12 @@ use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
||||||
*
|
*
|
||||||
* @ingroup container
|
* @ingroup container
|
||||||
*/
|
*/
|
||||||
class CoreServiceProvider implements ServiceProviderInterface {
|
class CoreServiceProvider implements ServiceProviderInterface, ServiceModifierInterface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function register(ContainerBuilder $container) {
|
public function register(ContainerBuilder $container) {
|
||||||
$this->registerUuid($container);
|
|
||||||
$this->registerTest($container);
|
$this->registerTest($container);
|
||||||
|
|
||||||
// Only register the private file stream wrapper if a file path has been set.
|
// Only register the private file stream wrapper if a file path has been set.
|
||||||
|
@ -98,30 +98,23 @@ class CoreServiceProvider implements ServiceProviderInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines and registers the UUID service.
|
* Alters the UUID service to use the most efficient method available.
|
||||||
*
|
*
|
||||||
* @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
|
* @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
|
||||||
* The container builder.
|
* The container builder.
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
* Class name for the UUID service.
|
|
||||||
*/
|
*/
|
||||||
public static function registerUuid(ContainerBuilder $container) {
|
public function alter(ContainerBuilder $container) {
|
||||||
$uuid_class = 'Drupal\Component\Uuid\Php';
|
$uuid_service = $container->getDefinition('uuid');
|
||||||
|
|
||||||
// Debian/Ubuntu uses the (broken) OSSP extension as their UUID
|
// Debian/Ubuntu uses the (broken) OSSP extension as their UUID
|
||||||
// implementation. The OSSP implementation is not compatible with the
|
// implementation. The OSSP implementation is not compatible with the
|
||||||
// PECL functions.
|
// PECL functions.
|
||||||
if (function_exists('uuid_create') && !function_exists('uuid_make')) {
|
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.
|
// Try to use the COM implementation for Windows users.
|
||||||
elseif (function_exists('com_create_guid')) {
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue