diff --git a/core/core.services.yml b/core/core.services.yml index 9a36139..3676718 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -60,7 +60,7 @@ services: arguments: ['@config.cachedstorage.storage', '@cache.config'] config.context.factory: class: Drupal\Core\Config\Context\ConfigContextFactory - arguments: ['@event_dispatcher'] + arguments: ['@event_dispatcher', '@uuid'] config.context: class: Drupal\Core\Config\Context\ContextInterface tags: diff --git a/core/includes/config.inc b/core/includes/config.inc index 31f6e5b..d2592b4 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -40,7 +40,8 @@ function config_install_default_config($type, $name) { Drupal::service('event_dispatcher'), Drupal::service('config.factory'), Drupal::entityManager(), - Drupal::lock() + Drupal::lock(), + Drupal::service('uuid') ); $installer->import(); } diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 32c0b49..6b2fb3f 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -354,7 +354,8 @@ function install_begin_request(&$install_state) { $container->register('config.storage', 'Drupal\Core\Config\InstallStorage'); $container->register('config.context.factory', 'Drupal\Core\Config\Context\ConfigContextFactory') - ->addArgument(new Reference('event_dispatcher')); + ->addArgument(new Reference('event_dispatcher')) + ->addArgument(new Reference('uuid')); $container->register('config.context', 'Drupal\Core\Config\Context\ContextInterface') ->setFactoryService(new Reference('config.context.factory')) @@ -406,6 +407,9 @@ function install_begin_request(&$install_state) { // Register Twig template engine for use during install. CoreBundle::registerTwig($container); + // Register Uuid. + CoreBundle::registerUuid($container); + Drupal::setContainer($container); } diff --git a/core/includes/update.inc b/core/includes/update.inc index a5feb50..4932d95 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -1554,7 +1554,7 @@ function update_variables_to_state(array $variable_map) { * A $primary_key values of rows to be updated. */ function update_add_uuids(&$sandbox, $table, $primary_key, $values) { - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); foreach ($values as $value) { db_update($table) ->fields(array( diff --git a/core/lib/Drupal/Component/Uuid/Com.php b/core/lib/Drupal/Component/Uuid/Com.php index 945a30b..df73a71 100644 --- a/core/lib/Drupal/Component/Uuid/Com.php +++ b/core/lib/Drupal/Component/Uuid/Com.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Component\Uuid\Com. + * Contains \Drupal\Component\Uuid\Com. */ namespace Drupal\Component\Uuid; @@ -12,9 +12,14 @@ * * @see http://php.net/com_create_guid */ -class Com implements UuidInterface { +class Com extends UuidBase implements UuidInterface { + + /** + * {@inheritdoc} + */ public function generate() { // Remove {} wrapper and make lower case to keep result consistent. return strtolower(trim(com_create_guid(), '{}')); } + } diff --git a/core/lib/Drupal/Component/Uuid/Pecl.php b/core/lib/Drupal/Component/Uuid/Pecl.php index 3d4cb27..32ff7cf 100644 --- a/core/lib/Drupal/Component/Uuid/Pecl.php +++ b/core/lib/Drupal/Component/Uuid/Pecl.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Component\Uuid\Pecl. + * Contains \Drupal\Component\Uuid\Pecl. */ namespace Drupal\Component\Uuid; @@ -10,12 +10,13 @@ /** * UUID implementation using the PECL extension. */ -class Pecl implements UuidInterface { +class Pecl extends UuidBase implements UuidInterface { /** - * Implements Drupal\Component\Uuid\UuidInterface::generate(). + * {@inheritdoc} */ public function generate() { return uuid_create(UUID_TYPE_DEFAULT); } + } diff --git a/core/lib/Drupal/Component/Uuid/Php.php b/core/lib/Drupal/Component/Uuid/Php.php index 3841f36..0991525 100644 --- a/core/lib/Drupal/Component/Uuid/Php.php +++ b/core/lib/Drupal/Component/Uuid/Php.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Component\Uuid\Php. + * Contains \Drupal\Component\Uuid\Php. */ namespace Drupal\Component\Uuid; @@ -16,10 +16,10 @@ * * @see http://uuidtools.rubyforge.org/api/classes/UUIDTools/UUID.html */ -class Php implements UuidInterface { +class Php extends UuidBase implements UuidInterface { /** - * Implements Drupal\Component\Uuid\UuidInterface::generate(). + * {@inheritdoc} */ public function generate() { $hex = substr(hash('sha256', Crypt::randomBytes(16)), 0, 32); @@ -46,4 +46,5 @@ public function generate() { return $uuid; } + } diff --git a/core/lib/Drupal/Component/Uuid/Uuid.php b/core/lib/Drupal/Component/Uuid/Uuid.php deleted file mode 100644 index 5df83ce..0000000 --- a/core/lib/Drupal/Component/Uuid/Uuid.php +++ /dev/null @@ -1,87 +0,0 @@ -determinePlugin(); - $this->plugin = new $class(); - } - - /** - * Generates a universally unique identifier. - * - * @see Drupal\Component\Uuid\UuidInterface::generate() - */ - public function generate() { - return $this->plugin->generate(); - } - - /** - * Checks that a string appears to be in the format of a UUID. - * - * Plugins should not implement validation, since UUIDs should be in a - * consistent format across all plugins. - * - * @param string $uuid - * The string to test. - * - * @return bool - * TRUE if the string is well formed, FALSE otherwise. - */ - public function isValid($uuid) { - return preg_match("/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/", $uuid); - } - - /** - * 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 string - * The class name for the optimal UUID generator. - */ - 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'; - } - // Try to use the COM implementation for Windows users. - elseif (function_exists('com_create_guid')) { - $plugin = 'Drupal\Component\Uuid\Com'; - } - return $plugin; - } -} diff --git a/core/lib/Drupal/Component/Uuid/UuidBase.php b/core/lib/Drupal/Component/Uuid/UuidBase.php new file mode 100644 index 0000000..40fb7d8 --- /dev/null +++ b/core/lib/Drupal/Component/Uuid/UuidBase.php @@ -0,0 +1,27 @@ +storageComparer = $storage_comparer; $this->eventDispatcher = $event_dispatcher; $this->configFactory = $config_factory; $this->entityManager = $entity_manager; $this->lock = $lock; + $this->uuidService = $uuid; $this->processed = $this->storageComparer->getEmptyChangelist(); // Use an override free context for importing so that overrides to do not // pollute the imported data. The context is hard coded to ensure this is // the case. - $this->context = new FreeConfigContext($this->eventDispatcher); + $this->context = new FreeConfigContext($this->eventDispatcher, $this->uuidService); } /** diff --git a/core/lib/Drupal/Core/Config/Context/ConfigContext.php b/core/lib/Drupal/Core/Config/Context/ConfigContext.php index a5382fd..fbd8b96 100644 --- a/core/lib/Drupal/Core/Config/Context/ConfigContext.php +++ b/core/lib/Drupal/Core/Config/Context/ConfigContext.php @@ -10,7 +10,7 @@ use Drupal\Core\Config\Config; use Drupal\Core\Config\ConfigEvent; use Drupal\Component\Utility\NestedArray; -use Drupal\Component\Uuid\Uuid; +use Drupal\Component\Uuid\UuidInterface; use Symfony\Component\EventDispatcher\EventDispatcher; /** @@ -50,13 +50,23 @@ class ConfigContext implements ContextInterface { protected $uuid; /** + * The Uuid service. + * + * @var \Drupal\Core\Component\Uuid\UuidInterface + */ + protected $uuidService; + + /** * Constructs the configuration context. * * @param \Symfony\Component\EventDispatcher\EventDispatcher $event_dispatcher * An event dispatcher instance to use for configuration events. + * @param \Drupal\Core\Component\Uuid\UuidInterface + * The Uuid service. */ - public function __construct(EventDispatcher $event_dispatcher) { + public function __construct(EventDispatcher $event_dispatcher, UuidInterface $uuid) { $this->eventDispatcher = $event_dispatcher; + $this->uuidService = $uuid; } /** @@ -89,8 +99,7 @@ public function set($key, $value) { * Implements \Drupal\Core\Config\Context\ContextInterface::setUuid(). */ public function setUuid() { - $uuid = new Uuid(); - $this->uuid = $uuid->generate(); + $this->uuid = $this->uuidService->generate(); } /** diff --git a/core/lib/Drupal/Core/Config/Context/ConfigContextFactory.php b/core/lib/Drupal/Core/Config/Context/ConfigContextFactory.php index 1642380..12a1ab9 100644 --- a/core/lib/Drupal/Core/Config/Context/ConfigContextFactory.php +++ b/core/lib/Drupal/Core/Config/Context/ConfigContextFactory.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\Config; use Drupal\Core\Config\ConfigException; +use Drupal\Component\Uuid\UuidInterface; use Symfony\Component\EventDispatcher\EventDispatcher; /** @@ -28,13 +29,23 @@ class ConfigContextFactory { protected $eventDispatcher; /** + * The Uuid service. + * + * @var \Drupal\Core\Component\Uuid\UuidInterface + */ + protected $uuidService; + + /** * Constructs the configuration context. * * @param \Symfony\Component\EventDispatcher\EventDispatcher $event_dispatcher * An event dispatcher instance to use for configuration events. + * @param \Drupal\Core\Component\Uuid\UuidInterface + * The Uuid service. */ - public function __construct(EventDispatcher $event_dispatcher) { + public function __construct(EventDispatcher $event_dispatcher, UuidInterface $uuid) { $this->eventDispatcher = $event_dispatcher; + $this->uuidService = $uuid; } /** @@ -52,7 +63,7 @@ public function get($class = NULL) { $class = 'Drupal\Core\Config\Context\ConfigContext'; } if (class_exists($class)) { - $context = new $class($this->eventDispatcher); + $context = new $class($this->eventDispatcher, $this->uuidService); } else { throw new ConfigException(sprintf('Unknown config context class: %s', $class)); diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index 095114a..848fe63 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Config\Entity; -use Drupal\Component\Uuid\Uuid; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityMalformedException; use Drupal\Core\Entity\EntityStorageControllerInterface; @@ -300,8 +299,8 @@ public function create(array $values) { // Assign a new UUID if there is none yet. if (!isset($entity->{$this->uuidKey})) { - $uuid = new Uuid(); - $entity->{$this->uuidKey} = $uuid->generate(); + // @todo use the Uuid service once we can inject into entity controllers. + $entity->{$this->uuidKey} = \Drupal::service('uuid')->generate(); } // Modules might need to add or change the data initially held by the new diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index 2d85f6a..ee7a79e 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -46,6 +46,7 @@ public function build(ContainerBuilder $container) { $container->addScope(new Scope('request')); $this->registerTwig($container); $this->registerModuleHandler($container); + $this->registerUuid($container); $container->addCompilerPass(new RegisterMatchersPass()); $container->addCompilerPass(new RegisterRouteFiltersPass()); @@ -116,4 +117,27 @@ public static function registerTwig(ContainerBuilder $container) { ->addMethodCall('addExtension', array(new Definition('Twig_Extension_Debug'))); } + /** + * Determines and registers the Uuid service. + * + * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container + * The container. + */ + 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); + } + } diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php index 6bb91e1..c44be50 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php @@ -10,7 +10,6 @@ use PDO; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Entity\Query\QueryInterface; -use Drupal\Component\Uuid\Uuid; use Drupal\Component\Utility\NestedArray; @@ -456,8 +455,8 @@ public function create(array $values) { // Assign a new UUID if there is none yet. if ($this->uuidKey && !isset($entity->{$this->uuidKey})) { - $uuid = new Uuid(); - $entity->{$this->uuidKey} = $uuid->generate(); + // @todo use the Uuid service once we can inject into entity controllers. + $entity->{$this->uuidKey} = \Drupal::service('uuid')->generate(); } // Modules might need to add or change the data initially held by the new diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php index 9b7020a..d0dc09a 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php @@ -112,8 +112,8 @@ public function create(array $values) { // Assign a new UUID if there is none yet. if ($this->uuidKey && !isset($entity->{$this->uuidKey}->value)) { - $uuid = new Uuid(); - $entity->{$this->uuidKey} = $uuid->generate(); + // @todo use the Uuid service once we can inject into entity controllers. + $entity->{$this->uuidKey} = \Drupal::service('uuid')->generate(); } // Modules might need to add or change the data initially held by the new diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index d48d0b7..0cb86bd 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Entity; -use Drupal\Component\Uuid\Uuid; use Drupal\Core\Language\Language; use Drupal\Core\TypedData\TypedDataInterface; use IteratorAggregate; @@ -353,8 +352,9 @@ public function createDuplicate() { // Check if the entity type supports UUIDs and generate a new one if so. if (!empty($entity_info['entity_keys']['uuid'])) { - $uuid = new Uuid(); - $duplicate->{$entity_info['entity_keys']['uuid']} = $uuid->generate(); + // @todo Inject the uuid service into the storage controller once + // possible. + $duplicate->{$entity_info['entity_keys']['uuid']} = \Drupal::service('uuid')->generate(); } return $duplicate; } diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index d9d17c2..4b79c2a 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -9,7 +9,6 @@ use Drupal\Core\Language\Language; use Drupal\Core\TypedData\TypedDataInterface; -use Drupal\Component\Uuid\Uuid; use ArrayIterator; use InvalidArgumentException; @@ -486,8 +485,9 @@ public function createDuplicate() { // Check if the entity type supports UUIDs and generate a new one if so. if (!empty($entity_info['entity_keys']['uuid'])) { - $uuid = new Uuid(); - $duplicate->{$entity_info['entity_keys']['uuid']}->value = $uuid->generate(); + // @todo Inject the uuid service into the storage controller once + // possible. + $duplicate->{$entity_info['entity_keys']['uuid']}->value = \Drupal::service('uuid')->generate(); } // Check whether the entity type supports revisions and initialize it if so. diff --git a/core/modules/block/block.install b/core/modules/block/block.install index bb9806e..379388f 100644 --- a/core/modules/block/block.install +++ b/core/modules/block/block.install @@ -193,7 +193,7 @@ function block_update_8007() { // Populate the {custom_block} and {custom_block_revision} table. $results = db_select('block_custom', 'bc')->fields('bc')->execute(); - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); $execute = FALSE; $block_insert = db_insert('custom_block')->fields(array( 'id', diff --git a/core/modules/config/config.admin.inc b/core/modules/config/config.admin.inc index a961286..cf45dd4 100644 --- a/core/modules/config/config.admin.inc +++ b/core/modules/config/config.admin.inc @@ -136,7 +136,8 @@ function config_admin_import_form_submit($form, &$form_state) { Drupal::service('event_dispatcher'), Drupal::service('config.factory'), Drupal::entityManager(), - Drupal::lock() + Drupal::lock(), + Drupal::service('uuid') ); if ($config_importer->alreadyImporting()) { drupal_set_message(t('Another request may be synchronizing configuration already.')); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php index 9d1e6be..482725f 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php @@ -58,7 +58,8 @@ function setUp() { $this->container->get('event_dispatcher'), $this->container->get('config.factory'), $this->container->get('plugin.manager.entity'), - $this->container->get('lock') + $this->container->get('lock'), + $this->container->get('uuid') ); } diff --git a/core/modules/contact/contact.install b/core/modules/contact/contact.install index d35abe9..dc51233 100644 --- a/core/modules/contact/contact.install +++ b/core/modules/contact/contact.install @@ -53,7 +53,7 @@ function contact_update_8000() { * @ingroup config_upgrade */ function contact_update_8001() { - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); $result = db_query('SELECT * FROM {contact}'); $ids = array(); foreach ($result as $category) { diff --git a/core/modules/entity/entity.install b/core/modules/entity/entity.install index af2aba1..27a448e 100644 --- a/core/modules/entity/entity.install +++ b/core/modules/entity/entity.install @@ -31,7 +31,7 @@ function _update_8000_entity_get_display($entity_type, $bundle, $view_mode) { } // Initialize a fresh structure. - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); $properties = array( 'id' => $id, 'uuid' => $uuid->generate(), @@ -70,7 +70,7 @@ function _update_8000_entity_get_form_display($entity_type, $bundle, $form_mode) } // Initialize a fresh structure. - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); $properties = array( 'id' => $id, 'uuid' => $uuid->generate(), diff --git a/core/modules/field/field.install b/core/modules/field/field.install index dc20e25..33e846b 100644 --- a/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -389,7 +389,7 @@ function field_update_8002() { * Convert fields and instances to config. */ function field_update_8003() { - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); $manifest_ids = array('fields' => array(), 'instances' => array()); $state = Drupal::state(); diff --git a/core/modules/filter/filter.install b/core/modules/filter/filter.install index 45955ad..1359d68 100644 --- a/core/modules/filter/filter.install +++ b/core/modules/filter/filter.install @@ -29,7 +29,7 @@ function filter_update_8000() { * @ingroup config_upgrade */ function filter_update_8001() { - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); $result = db_query('SELECT format, name, cache, status, weight FROM {filter_format}', array(), array('fetch' => PDO::FETCH_ASSOC)); foreach ($result as $format) { $id = $format['format']; diff --git a/core/modules/image/image.install b/core/modules/image/image.install index 8a05660..176a5dc 100644 --- a/core/modules/image/image.install +++ b/core/modules/image/image.install @@ -129,7 +129,7 @@ function _image_update_get_style_with_effects(array $style) { $effect['data'] = unserialize($effect['data']); // Generate a unique image effect ID for the effect. - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); $effect['ieid'] = $uuid->generate(); $effects[$effect['ieid']] = $effect; diff --git a/core/modules/image/image.module b/core/modules/image/image.module index a7696a6..e523f1e 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -918,7 +918,7 @@ function image_effect_save($style, &$effect) { // Generate a unique image effect ID for a new effect. if (empty($effect['ieid'])) { - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); $effect['ieid'] = $uuid->generate(); } $style->effects[$effect['ieid']] = $effect; diff --git a/core/modules/menu/menu.install b/core/modules/menu/menu.install index a76207b..09c3827 100644 --- a/core/modules/menu/menu.install +++ b/core/modules/menu/menu.install @@ -76,7 +76,7 @@ function menu_update_8003() { * @ingroup config_upgrade */ function menu_update_8004() { - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); $result = db_query('SELECT * FROM {menu_custom}'); foreach ($result as $menu) { // Save the config object. diff --git a/core/modules/shortcut/shortcut.install b/core/modules/shortcut/shortcut.install index 4a84150..5142b30 100644 --- a/core/modules/shortcut/shortcut.install +++ b/core/modules/shortcut/shortcut.install @@ -68,7 +68,7 @@ function shortcut_schema() { * Migrate shortcuts into configuration. */ function shortcut_update_8000() { - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); $result = db_query('SELECT * from {shortcut_set}'); $ids = array(); foreach ($result as $set) { diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 6e791b3..4ce151d 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -1299,7 +1299,8 @@ public function configImporter() { $this->container->get('event_dispatcher'), $this->container->get('config.factory'), $this->container->get('plugin.manager.entity'), - $this->container->get('lock') + $this->container->get('lock'), + $this->container->get('uuid') ); } // Always recalculate the changelist when called. diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUUIDTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUUIDTest.php index 0168bb3..c327295 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUUIDTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUUIDTest.php @@ -54,7 +54,7 @@ function testCRUD() { */ protected function assertCRUD($entity_type) { // Verify that no UUID is auto-generated when passing one for creation. - $uuid_service = new Uuid(); + $uuid_service = $this->container->get('uuid'); $uuid = $uuid_service->generate(); $custom_entity = entity_create($entity_type, array( 'name' => $this->randomName(), diff --git a/core/modules/system/lib/Drupal/system/Tests/Uuid/UuidUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Uuid/UuidUnitTest.php index 579ff33..29e547f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Uuid/UuidUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Uuid/UuidUnitTest.php @@ -32,7 +32,7 @@ public static function getInfo() { public function setUp() { // Initiate the generator. This will lazy-load uuid.inc. - $this->uuid = new Uuid(); + $this->uuid = $this->container->get('uuid'); parent::setUp(); } diff --git a/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install index d89b89c..edbceeb 100644 --- a/core/modules/taxonomy/taxonomy.install +++ b/core/modules/taxonomy/taxonomy.install @@ -295,7 +295,7 @@ function taxonomy_update_8004() { * Convert vocabularies into configuration. */ function taxonomy_update_8005() { - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); $result = db_query('SELECT * FROM {taxonomy_vocabulary}'); foreach ($result as $vocabulary) { diff --git a/core/modules/user/user.install b/core/modules/user/user.install index 4f22958..00c4f51 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -679,7 +679,7 @@ function user_update_8011() { // of file_save_data() by updating an eventually existing record for that // file. file_unmanaged_save_data($default_image, $destination, FILE_EXISTS_REPLACE); - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); db_merge('file_managed') ->key(array( 'uri' => $destination, @@ -1034,7 +1034,7 @@ function user_update_8016() { * @ingroup config_upgrade */ function user_update_8017() { - $uuid = new Uuid(); + $uuid = Drupal::service('uuid'); $roles = db_select('role', 'r') ->fields('r') diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewTestData.php b/core/modules/views/lib/Drupal/views/Tests/ViewTestData.php index 3f2bfd1..e08d7dd 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewTestData.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestData.php @@ -66,7 +66,8 @@ public static function importTestViews($class, $modules = array()) { \Drupal::service('event_dispatcher'), \Drupal::service('config.factory'), \Drupal::entityManager(), - \Drupal::lock() + \Drupal::lock(), + \Drupal::service('uuid') ); $installer->import(); }