Issue #3419914 by Spokje, longwave, andypost, smustgrave: Remove UpdateHookRegistryFactory and UpdateRegistryFactory services
(cherry picked from commit e5c3c870e3
)
merge-requests/6880/head
parent
9358fca0f9
commit
36f5209c29
|
@ -1790,17 +1790,19 @@ services:
|
|||
Drupal\Component\Utility\EmailValidatorInterface: '@email.validator'
|
||||
update.update_hook_registry:
|
||||
class: Drupal\Core\Update\UpdateHookRegistry
|
||||
factory: ['@update.update_hook_registry_factory', create]
|
||||
arguments: ['%container.modules%', '@keyvalue']
|
||||
Drupal\Core\Update\UpdateHookRegistry: '@update.update_hook_registry'
|
||||
update.update_hook_registry_factory:
|
||||
class: Drupal\Core\Update\UpdateHookRegistryFactory
|
||||
parent: container.trait
|
||||
deprecated: The "%service_id%" service is deprecated. You should use the 'update.update_hook_registry' service instead. See https://www.drupal.org/node/3423659
|
||||
update.post_update_registry:
|
||||
class: Drupal\Core\Update\UpdateRegistry
|
||||
factory: ['@update.post_update_registry_factory', create]
|
||||
arguments: [ '%app.root%', '%site.path%', '%container.modules%', '@keyvalue', '@theme_handler' ]
|
||||
update.post_update_registry_factory:
|
||||
class: Drupal\Core\Update\UpdateRegistryFactory
|
||||
parent: container.trait
|
||||
deprecated: The "%service_id%" service is deprecated. You should use the 'update.post_update_registry' service instead. See https://www.drupal.org/node/3423659
|
||||
uuid:
|
||||
class: Drupal\Component\Uuid\Php
|
||||
Drupal\Component\Uuid\UuidInterface: '@uuid'
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Drupal\Core\Update;
|
||||
|
||||
use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
|
||||
use Drupal\Core\KeyValueStore\KeyValueStoreInterface;
|
||||
|
||||
/**
|
||||
|
@ -50,16 +51,24 @@ class UpdateHookRegistry {
|
|||
protected $allAvailableSchemaVersions = [];
|
||||
|
||||
/**
|
||||
* Constructs a new UpdateRegistry.
|
||||
* Constructs a new UpdateHookRegistry.
|
||||
*
|
||||
* @param string[] $enabled_modules
|
||||
* A list of enabled modules.
|
||||
* @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $key_value
|
||||
* The key value store.
|
||||
* @param array $module_list
|
||||
* An associative array whose keys are the names of installed modules.
|
||||
* @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface|\Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory
|
||||
* The key value factory.
|
||||
*/
|
||||
public function __construct(array $enabled_modules, KeyValueStoreInterface $key_value) {
|
||||
$this->enabledModules = $enabled_modules;
|
||||
$this->keyValue = $key_value;
|
||||
public function __construct(array $module_list, KeyValueStoreInterface|KeyValueFactoryInterface $key_value_factory) {
|
||||
if ($module_list !== [] && array_is_list($module_list)) {
|
||||
@trigger_error('Calling ' . __METHOD__ . '() with the $enabled_modules argument is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use an associative array whose keys are the names of installed modules instead. See https://www.drupal.org/node/3423659', E_USER_DEPRECATED);
|
||||
$module_list = \Drupal::service('module_handler')->getModuleList();
|
||||
}
|
||||
if ($key_value_factory instanceof KeyValueStoreInterface) {
|
||||
@trigger_error('Calling ' . __METHOD__ . '() with the $key_value_factory argument as a KeyValueStoreInterface instead of a KeyValueFactoryInterface is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3423659', E_USER_DEPRECATED);
|
||||
$key_value_factory = \Drupal::service('keyvalue');
|
||||
}
|
||||
$this->enabledModules = array_keys($module_list);
|
||||
$this->keyValue = $key_value_factory->get('system.schema');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,11 +7,22 @@ use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
|||
|
||||
/**
|
||||
* Service factory for the versioning update registry.
|
||||
*
|
||||
* @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use
|
||||
* \Drupal\Core\Update\UpdateHookRegistry instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3423659
|
||||
*/
|
||||
class UpdateHookRegistryFactory implements ContainerAwareInterface {
|
||||
|
||||
use ContainerAwareTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new UpdateHookRegistry instance.
|
||||
*
|
||||
|
@ -19,9 +30,10 @@ class UpdateHookRegistryFactory implements ContainerAwareInterface {
|
|||
* The update registry instance.
|
||||
*/
|
||||
public function create() {
|
||||
@trigger_error(__NAMESPACE__ . '\UpdateHookRegistryFactory is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Update\UpdateHookRegistry instead. See https://www.drupal.org/node/3423659', E_USER_DEPRECATED);
|
||||
return new UpdateHookRegistry(
|
||||
array_keys($this->container->get('module_handler')->getModuleList()),
|
||||
$this->container->get('keyvalue')->get('system.schema')
|
||||
$this->container->get('module_handler')->getModuleList(),
|
||||
$this->container->get('keyvalue')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ use Drupal\Core\Config\ConfigCrudEvent;
|
|||
use Drupal\Core\Config\ConfigEvents;
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\Extension\ExtensionDiscovery;
|
||||
use Drupal\Core\KeyValueStore\KeyValueStoreInterface;
|
||||
use Drupal\Core\Extension\ThemeHandlerInterface;
|
||||
use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
// cspell:ignore updatetype
|
||||
|
@ -55,13 +56,6 @@ class UpdateRegistry implements EventSubscriberInterface {
|
|||
*/
|
||||
protected $keyValue;
|
||||
|
||||
/**
|
||||
* Should we respect update functions in tests.
|
||||
*
|
||||
* @var bool|null
|
||||
*/
|
||||
protected $includeTests = NULL;
|
||||
|
||||
/**
|
||||
* The site path.
|
||||
*
|
||||
|
@ -86,19 +80,26 @@ class UpdateRegistry implements EventSubscriberInterface {
|
|||
* The app root.
|
||||
* @param string $site_path
|
||||
* The site path.
|
||||
* @param string[] $enabled_extensions
|
||||
* A list of enabled extensions.
|
||||
* @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $key_value
|
||||
* The key value store.
|
||||
* @param bool|null $include_tests
|
||||
* (optional) A flag whether to include tests in the scanning of extensions.
|
||||
* @param array $module_list
|
||||
* An associative array whose keys are the names of installed modules.
|
||||
* @param \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory
|
||||
* The key value factory.
|
||||
* @param \Drupal\Core\Extension\ThemeHandlerInterface|bool|null $theme_handler
|
||||
* The theme handler.
|
||||
*/
|
||||
public function __construct($root, $site_path, array $enabled_extensions, KeyValueStoreInterface $key_value, $include_tests = NULL) {
|
||||
public function __construct($root, $site_path, $module_list, KeyValueFactoryInterface $key_value_factory, ThemeHandlerInterface|bool $theme_handler = NULL) {
|
||||
$this->root = $root;
|
||||
$this->sitePath = $site_path;
|
||||
$this->enabledExtensions = $enabled_extensions;
|
||||
$this->keyValue = $key_value;
|
||||
$this->includeTests = $include_tests;
|
||||
if ($module_list !== [] && array_is_list($module_list)) {
|
||||
@trigger_error('Calling ' . __METHOD__ . '() with the $enabled_extensions argument is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use an associative array whose keys are the names of installed modules instead. See https://www.drupal.org/node/3423659', E_USER_DEPRECATED);
|
||||
$module_list = \Drupal::service('module_handler')->getModuleList();
|
||||
}
|
||||
if ($theme_handler === NULL || is_bool($theme_handler)) {
|
||||
@trigger_error('Calling ' . __METHOD__ . '() with the $include_tests argument is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/3423659', E_USER_DEPRECATED);
|
||||
$theme_handler = \Drupal::service('theme_handler');
|
||||
}
|
||||
$this->enabledExtensions = array_merge(array_keys($module_list), array_keys($theme_handler->listInfo()));
|
||||
$this->keyValue = $key_value_factory->get('post_update');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,6 +7,11 @@ use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
|||
|
||||
/**
|
||||
* Service factory for the update registry.
|
||||
*
|
||||
* @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use
|
||||
* \Drupal\Core\Update\UpdateRegistry instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3423659
|
||||
*/
|
||||
class UpdateRegistryFactory implements ContainerAwareInterface {
|
||||
|
||||
|
@ -19,8 +24,14 @@ class UpdateRegistryFactory implements ContainerAwareInterface {
|
|||
* The update registry instance.
|
||||
*/
|
||||
public function create() {
|
||||
$extensions = array_merge(array_keys($this->container->get('module_handler')->getModuleList()), array_keys($this->container->get('theme_handler')->listInfo()));
|
||||
return new UpdateRegistry($this->container->getParameter('app.root'), $this->container->getParameter('site.path'), $extensions, $this->container->get('keyvalue')->get('post_update'));
|
||||
@trigger_error(__NAMESPACE__ . '\UpdateHookRegistryFactory is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Update\UpdateRegistry instead. See https://www.drupal.org/node/3423659', E_USER_DEPRECATED);
|
||||
return new UpdateRegistry(
|
||||
$this->container->getParameter('app.root'),
|
||||
$this->container->getParameter('site.path'),
|
||||
$this->container->get('module_handler')->getModuleList(),
|
||||
$this->container->get('keyvalue'),
|
||||
$this->container->get('theme_handler')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -844,43 +844,11 @@ parameters:
|
|||
count: 1
|
||||
path: lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php
|
||||
|
||||
-
|
||||
message: """
|
||||
#^Class Drupal\\\\Core\\\\Update\\\\UpdateHookRegistryFactory implements deprecated interface Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareInterface\\:
|
||||
since Symfony 6\\.4, use dependency injection instead$#
|
||||
"""
|
||||
count: 1
|
||||
path: lib/Drupal/Core/Update/UpdateHookRegistryFactory.php
|
||||
|
||||
-
|
||||
message: """
|
||||
#^Usage of deprecated trait Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareTrait in class Drupal\\\\Core\\\\Update\\\\UpdateHookRegistryFactory\\:
|
||||
since Symfony 6\\.4, use dependency injection instead$#
|
||||
"""
|
||||
count: 1
|
||||
path: lib/Drupal/Core/Update/UpdateHookRegistryFactory.php
|
||||
|
||||
-
|
||||
message: "#^Method Drupal\\\\Core\\\\Update\\\\UpdateKernel\\:\\:discoverServiceProviders\\(\\) should return array but return statement is missing\\.$#"
|
||||
count: 1
|
||||
path: lib/Drupal/Core/Update/UpdateKernel.php
|
||||
|
||||
-
|
||||
message: """
|
||||
#^Class Drupal\\\\Core\\\\Update\\\\UpdateRegistryFactory implements deprecated interface Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareInterface\\:
|
||||
since Symfony 6\\.4, use dependency injection instead$#
|
||||
"""
|
||||
count: 1
|
||||
path: lib/Drupal/Core/Update/UpdateRegistryFactory.php
|
||||
|
||||
-
|
||||
message: """
|
||||
#^Usage of deprecated trait Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareTrait in class Drupal\\\\Core\\\\Update\\\\UpdateRegistryFactory\\:
|
||||
since Symfony 6\\.4, use dependency injection instead$#
|
||||
"""
|
||||
count: 1
|
||||
path: lib/Drupal/Core/Update/UpdateRegistryFactory.php
|
||||
|
||||
-
|
||||
message: "#^Method Drupal\\\\Core\\\\Updater\\\\Module\\:\\:postUpdateTasks\\(\\) should return array but return statement is missing\\.$#"
|
||||
count: 1
|
||||
|
|
|
@ -93,7 +93,7 @@ class UpdateHookRegistryTest extends UnitTestCase {
|
|||
public function testGetVersions() {
|
||||
$module_name = 'drupal\tests\core\update\under_test';
|
||||
|
||||
$update_registry = new UpdateHookRegistry([], $this->keyValueStore);
|
||||
$update_registry = new UpdateHookRegistry([], $this->keyValueFactory);
|
||||
|
||||
// Only under_test_update_X - passes through the filter.
|
||||
$expected = [1, 20, 3000];
|
||||
|
@ -136,7 +136,7 @@ class UpdateHookRegistryTest extends UnitTestCase {
|
|||
$versions[$key] = $value;
|
||||
});
|
||||
|
||||
$update_registry = new UpdateHookRegistry([], $this->keyValueStore);
|
||||
$update_registry = new UpdateHookRegistry([], $this->keyValueFactory);
|
||||
|
||||
$this->assertSame(3000, $update_registry->getInstalledVersion('module3'));
|
||||
$update_registry->setInstalledVersion('module3', 3001);
|
||||
|
|
|
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Drupal\Tests\Core\Update;
|
||||
|
||||
use Drupal\Core\Extension\ThemeHandlerInterface;
|
||||
use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
|
||||
use Drupal\Core\KeyValueStore\KeyValueStoreInterface;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Drupal\Core\Update\RemovedPostUpdateNameException;
|
||||
|
@ -188,11 +190,33 @@ EOS;
|
|||
$key_value->get('existing_updates', [])->willReturn([]);
|
||||
$key_value = $key_value->reveal();
|
||||
|
||||
$key_value_factory = $this->prophesize(KeyValueFactoryInterface::class);
|
||||
$key_value_factory->get('post_update')->willReturn($key_value);
|
||||
$key_value_factory = $key_value_factory->reveal();
|
||||
|
||||
$theme_handler = $this->prophesize(ThemeHandlerInterface::class);
|
||||
$theme_handler->listInfo()->willReturn([
|
||||
'theme_d' => [
|
||||
'type' => 'theme_d',
|
||||
'pathname' => 'core/themes/theme_d/theme_d.info.yml',
|
||||
],
|
||||
]);
|
||||
$theme_handler = $theme_handler->reveal();
|
||||
|
||||
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
|
||||
'module_a',
|
||||
'module_b',
|
||||
'theme_d',
|
||||
], $key_value, FALSE);
|
||||
'module_a' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_a/module_a.info.yml',
|
||||
'filename' => 'module_a.module',
|
||||
],
|
||||
'module_b' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_b/module_b.info.yml',
|
||||
'filename' => 'module_b.module',
|
||||
],
|
||||
], $key_value_factory, $theme_handler);
|
||||
|
||||
$this->assertEquals([
|
||||
'module_a_post_update_a',
|
||||
|
@ -213,14 +237,27 @@ EOS;
|
|||
$key_value->get('existing_updates', [])->willReturn([]);
|
||||
$key_value = $key_value->reveal();
|
||||
|
||||
$key_value_factory = $this->prophesize(KeyValueFactoryInterface::class);
|
||||
$key_value_factory->get('post_update')->willReturn($key_value);
|
||||
$key_value_factory = $key_value_factory->reveal();
|
||||
|
||||
$theme_handler = $this->prophesize(ThemeHandlerInterface::class);
|
||||
$theme_handler->listInfo()->willReturn([]);
|
||||
$theme_handler = $theme_handler->reveal();
|
||||
|
||||
// Preload modules to ensure that ::getAvailableUpdateFunctions filters out
|
||||
// not enabled modules.
|
||||
include_once 'vfs://drupal/sites/default/modules/module_a/module_a.post_update.php';
|
||||
include_once 'vfs://drupal/sites/default/modules/module_b/module_b.post_update.php';
|
||||
|
||||
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
|
||||
'module_a',
|
||||
], $key_value, FALSE);
|
||||
'module_a' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_a/module_a.info.yml',
|
||||
'filename' => 'module_a.module',
|
||||
],
|
||||
], $key_value_factory, $theme_handler);
|
||||
|
||||
$this->assertEquals([
|
||||
'module_a_post_update_a',
|
||||
|
@ -235,14 +272,40 @@ EOS;
|
|||
$this->setupBasicExtensions();
|
||||
|
||||
$key_value = $this->prophesize(KeyValueStoreInterface::class);
|
||||
$key_value->get('existing_updates', [])->willReturn(['module_a_post_update_a', 'theme_d_post_update_a', 'theme_d_post_update_b']);
|
||||
$key_value->get('existing_updates', [])->willReturn([
|
||||
'module_a_post_update_a',
|
||||
'theme_d_post_update_a',
|
||||
'theme_d_post_update_b',
|
||||
]);
|
||||
$key_value = $key_value->reveal();
|
||||
|
||||
$key_value_factory = $this->prophesize(KeyValueFactoryInterface::class);
|
||||
$key_value_factory->get('post_update')->willReturn($key_value);
|
||||
$key_value_factory = $key_value_factory->reveal();
|
||||
|
||||
$theme_handler = $this->prophesize(ThemeHandlerInterface::class);
|
||||
$theme_handler->listInfo()->willReturn([
|
||||
'theme_d' => [
|
||||
'type' => 'theme_d',
|
||||
'pathname' => 'core/themes/theme_d/theme_d.info.yml',
|
||||
],
|
||||
]);
|
||||
$theme_handler = $theme_handler->reveal();
|
||||
|
||||
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
|
||||
'module_a',
|
||||
'module_b',
|
||||
'theme_d',
|
||||
], $key_value, FALSE);
|
||||
'module_a' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_a/module_a.info.yml',
|
||||
'filename' => 'module_a.module',
|
||||
],
|
||||
'module_b' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_b/module_b.info.yml',
|
||||
'filename' => 'module_b.module',
|
||||
],
|
||||
], $key_value_factory, $theme_handler);
|
||||
|
||||
$this->assertEquals(array_values([
|
||||
'module_a_post_update_b',
|
||||
|
@ -262,11 +325,33 @@ EOS;
|
|||
$key_value->get('existing_updates', [])->willReturn([]);
|
||||
$key_value = $key_value->reveal();
|
||||
|
||||
$key_value_factory = $this->prophesize(KeyValueFactoryInterface::class);
|
||||
$key_value_factory->get('post_update')->willReturn($key_value);
|
||||
$key_value_factory = $key_value_factory->reveal();
|
||||
|
||||
$theme_handler = $this->prophesize(ThemeHandlerInterface::class);
|
||||
$theme_handler->listInfo()->willReturn([
|
||||
'theme_d' => [
|
||||
'type' => 'theme_d',
|
||||
'pathname' => 'core/themes/theme_d/theme_d.info.yml',
|
||||
],
|
||||
]);
|
||||
$theme_handler = $theme_handler->reveal();
|
||||
|
||||
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
|
||||
'module_a',
|
||||
'module_b',
|
||||
'theme_d',
|
||||
], $key_value, FALSE);
|
||||
'module_a' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_a/module_a.info.yml',
|
||||
'filename' => 'module_a.module',
|
||||
],
|
||||
'module_b' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_b/module_b.info.yml',
|
||||
'filename' => 'module_b.module',
|
||||
],
|
||||
], $key_value_factory, $theme_handler);
|
||||
|
||||
$expected = [];
|
||||
$expected['module_a']['pending']['a'] = 'Module A update A.';
|
||||
|
@ -288,14 +373,40 @@ EOS;
|
|||
$this->setupBasicExtensions();
|
||||
|
||||
$key_value = $this->prophesize(KeyValueStoreInterface::class);
|
||||
$key_value->get('existing_updates', [])->willReturn(['module_a_post_update_a', 'theme_d_post_update_a', 'theme_d_post_update_b']);
|
||||
$key_value->get('existing_updates', [])->willReturn([
|
||||
'module_a_post_update_a',
|
||||
'theme_d_post_update_a',
|
||||
'theme_d_post_update_b',
|
||||
]);
|
||||
$key_value = $key_value->reveal();
|
||||
|
||||
$key_value_factory = $this->prophesize(KeyValueFactoryInterface::class);
|
||||
$key_value_factory->get('post_update')->willReturn($key_value);
|
||||
$key_value_factory = $key_value_factory->reveal();
|
||||
|
||||
$theme_handler = $this->prophesize(ThemeHandlerInterface::class);
|
||||
$theme_handler->listInfo()->willReturn([
|
||||
'theme_d' => [
|
||||
'type' => 'theme_d',
|
||||
'pathname' => 'core/themes/theme_d/theme_d.info.yml',
|
||||
],
|
||||
]);
|
||||
$theme_handler = $theme_handler->reveal();
|
||||
|
||||
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
|
||||
'module_a',
|
||||
'module_b',
|
||||
'theme_d',
|
||||
], $key_value, FALSE);
|
||||
'module_a' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_a/module_a.info.yml',
|
||||
'filename' => 'module_a.module',
|
||||
],
|
||||
'module_b' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_b/module_b.info.yml',
|
||||
'filename' => 'module_b.module',
|
||||
],
|
||||
], $key_value_factory, $theme_handler);
|
||||
|
||||
$expected = [];
|
||||
$expected['module_a']['pending']['b'] = 'Module A update B.';
|
||||
|
@ -318,9 +429,22 @@ EOS;
|
|||
$key_value->get('existing_updates', [])->willReturn(['module_a_post_update_a']);
|
||||
$key_value = $key_value->reveal();
|
||||
|
||||
$key_value_factory = $this->prophesize(KeyValueFactoryInterface::class);
|
||||
$key_value_factory->get('post_update')->willReturn($key_value);
|
||||
$key_value_factory = $key_value_factory->reveal();
|
||||
|
||||
$theme_handler = $this->prophesize(ThemeHandlerInterface::class);
|
||||
$theme_handler->listInfo()->willReturn([]);
|
||||
$theme_handler = $theme_handler->reveal();
|
||||
|
||||
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
|
||||
'module_c',
|
||||
], $key_value, FALSE);
|
||||
'module_c' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_c/module_c.info.yml',
|
||||
'filename' => 'module_c.module',
|
||||
],
|
||||
], $key_value_factory, $theme_handler);
|
||||
|
||||
$this->expectException(RemovedPostUpdateNameException::class);
|
||||
$update_registry->getPendingUpdateInformation();
|
||||
|
@ -333,11 +457,33 @@ EOS;
|
|||
$this->setupBasicExtensions();
|
||||
$key_value = $this->prophesize(KeyValueStoreInterface::class)->reveal();
|
||||
|
||||
$key_value_factory = $this->prophesize(KeyValueFactoryInterface::class);
|
||||
$key_value_factory->get('post_update')->willReturn($key_value);
|
||||
$key_value_factory = $key_value_factory->reveal();
|
||||
|
||||
$theme_handler = $this->prophesize(ThemeHandlerInterface::class);
|
||||
$theme_handler->listInfo()->willReturn([
|
||||
'theme_d' => [
|
||||
'type' => 'theme_d',
|
||||
'pathname' => 'core/themes/theme_d/theme_d.info.yml',
|
||||
],
|
||||
]);
|
||||
$theme_handler = $theme_handler->reveal();
|
||||
|
||||
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
|
||||
'module_a',
|
||||
'module_b',
|
||||
'theme_d',
|
||||
], $key_value, FALSE);
|
||||
'module_a' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_a/module_a.info.yml',
|
||||
'filename' => 'module_a.module',
|
||||
],
|
||||
'module_b' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_b/module_b.info.yml',
|
||||
'filename' => 'module_b.module',
|
||||
],
|
||||
], $key_value_factory, $theme_handler);
|
||||
|
||||
$this->assertEquals(['module_a_post_update_a', 'module_a_post_update_b'], array_values($update_registry->getUpdateFunctions('module_a')));
|
||||
$this->assertEquals(['module_b_post_update_a'], array_values($update_registry->getUpdateFunctions('module_b')));
|
||||
|
@ -358,11 +504,33 @@ EOS;
|
|||
->shouldBeCalledTimes(1);
|
||||
$key_value = $key_value->reveal();
|
||||
|
||||
$key_value_factory = $this->prophesize(KeyValueFactoryInterface::class);
|
||||
$key_value_factory->get('post_update')->willReturn($key_value);
|
||||
$key_value_factory = $key_value_factory->reveal();
|
||||
|
||||
$theme_handler = $this->prophesize(ThemeHandlerInterface::class);
|
||||
$theme_handler->listInfo()->willReturn([
|
||||
'theme_d' => [
|
||||
'type' => 'theme_d',
|
||||
'pathname' => 'core/themes/theme_d/theme_d.info.yml',
|
||||
],
|
||||
]);
|
||||
$theme_handler = $theme_handler->reveal();
|
||||
|
||||
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
|
||||
'module_a',
|
||||
'module_b',
|
||||
'theme_d',
|
||||
], $key_value, FALSE);
|
||||
'module_a' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_a/module_a.info.yml',
|
||||
'filename' => 'module_a.module',
|
||||
],
|
||||
'module_b' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_b/module_b.info.yml',
|
||||
'filename' => 'module_b.module',
|
||||
],
|
||||
], $key_value_factory, $theme_handler);
|
||||
$update_registry->registerInvokedUpdates(['module_a_post_update_a']);
|
||||
}
|
||||
|
||||
|
@ -380,11 +548,33 @@ EOS;
|
|||
->shouldBeCalledTimes(1);
|
||||
$key_value = $key_value->reveal();
|
||||
|
||||
$key_value_factory = $this->prophesize(KeyValueFactoryInterface::class);
|
||||
$key_value_factory->get('post_update')->willReturn($key_value);
|
||||
$key_value_factory = $key_value_factory->reveal();
|
||||
|
||||
$theme_handler = $this->prophesize(ThemeHandlerInterface::class);
|
||||
$theme_handler->listInfo()->willReturn([
|
||||
'theme_d' => [
|
||||
'type' => 'theme_d',
|
||||
'pathname' => 'core/themes/theme_d/theme_d.info.yml',
|
||||
],
|
||||
]);
|
||||
$theme_handler = $theme_handler->reveal();
|
||||
|
||||
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
|
||||
'module_a',
|
||||
'module_b',
|
||||
'theme_d',
|
||||
], $key_value, FALSE);
|
||||
'module_a' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_a/module_a.info.yml',
|
||||
'filename' => 'module_a.module',
|
||||
],
|
||||
'module_b' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_b/module_b.info.yml',
|
||||
'filename' => 'module_b.module',
|
||||
],
|
||||
], $key_value_factory, $theme_handler);
|
||||
$update_registry->registerInvokedUpdates(['module_a_post_update_a', 'module_a_post_update_b', 'theme_d_post_update_c']);
|
||||
}
|
||||
|
||||
|
@ -402,10 +592,28 @@ EOS;
|
|||
->shouldBeCalledTimes(1);
|
||||
$key_value = $key_value->reveal();
|
||||
|
||||
$key_value_factory = $this->prophesize(KeyValueFactoryInterface::class);
|
||||
$key_value_factory->get('post_update')->willReturn($key_value);
|
||||
$key_value_factory = $key_value_factory->reveal();
|
||||
|
||||
$theme_handler = $this->prophesize(ThemeHandlerInterface::class);
|
||||
$theme_handler->listInfo()->willReturn([]);
|
||||
$theme_handler = $theme_handler->reveal();
|
||||
|
||||
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
|
||||
'module_a',
|
||||
'module_b',
|
||||
], $key_value, FALSE);
|
||||
'module_a' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_a/module_a.info.yml',
|
||||
'filename' => 'module_a.module',
|
||||
],
|
||||
'module_b' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_b/module_b.info.yml',
|
||||
'filename' => 'module_b.module',
|
||||
],
|
||||
], $key_value_factory, $theme_handler);
|
||||
$update_registry->registerInvokedUpdates(['module_a_post_update_a']);
|
||||
}
|
||||
|
||||
|
@ -423,12 +631,33 @@ EOS;
|
|||
->shouldBeCalledTimes(1);
|
||||
$key_value = $key_value->reveal();
|
||||
|
||||
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
|
||||
'module_a',
|
||||
'module_b',
|
||||
'theme_d',
|
||||
], $key_value, FALSE);
|
||||
$key_value_factory = $this->prophesize(KeyValueFactoryInterface::class);
|
||||
$key_value_factory->get('post_update')->willReturn($key_value);
|
||||
$key_value_factory = $key_value_factory->reveal();
|
||||
|
||||
$theme_handler = $this->prophesize(ThemeHandlerInterface::class);
|
||||
$theme_handler->listInfo()->willReturn([
|
||||
'theme_d' => [
|
||||
'type' => 'theme_d',
|
||||
'pathname' => 'core/themes/theme_d/theme_d.info.yml',
|
||||
],
|
||||
]);
|
||||
$theme_handler = $theme_handler->reveal();
|
||||
|
||||
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
|
||||
'module_a' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_a/module_a.info.yml',
|
||||
'filename' => 'module_a.module',
|
||||
],
|
||||
'module_b' =>
|
||||
[
|
||||
'type' => 'module',
|
||||
'pathname' => 'core/modules/module_b/module_b.info.yml',
|
||||
'filename' => 'module_b.module',
|
||||
],
|
||||
], $key_value_factory, $theme_handler);
|
||||
$update_registry->filterOutInvokedUpdatesByExtension('module_a');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue