diff --git a/config/install/multiversion.settings.yml b/config/install/multiversion.settings.yml old mode 100644 new mode 100755 index 2429f30..3d015a9 --- a/config/install/multiversion.settings.yml +++ b/config/install/multiversion.settings.yml @@ -21,6 +21,7 @@ supported_entity_types: - poll - poll_choice - redirect + - path_alias #Entity types enabled by Multiversion. When Multiversion is installed it will enable all supported entity types if they #exist (if the module that provides the entity type is enabled). enabled_entity_types: { } diff --git a/multiversion.info.yml b/multiversion.info.yml old mode 100644 new mode 100755 index a6f4133..e56e6e1 --- a/multiversion.info.yml +++ b/multiversion.info.yml @@ -2,13 +2,14 @@ name: Multiversion type: module description: 'Extends the revision support for content entities.' version: VERSION -core: 8.x +core_version_requirement: ^8 || ^9 dependencies: - drupal:serialization - drupal:system (>=8.4.0) - key_value:key_value - conflict:conflict + - drupal:path_alias test_dependencies: - paragraphs:paragraphs - entity_reference_revisions:entity_reference_revisions - - poll:poll + - poll:poll \ No newline at end of file diff --git a/multiversion.install b/multiversion.install old mode 100644 new mode 100755 index cb35ccd..0b67c23 --- a/multiversion.install +++ b/multiversion.install @@ -41,7 +41,9 @@ function multiversion_install() { _multiversion_update_uuid_fields(); - _multiversion_add_workspace_field_in_url_alias_table(TRUE); + if (version_compare(\Drupal::VERSION, '8.8', '<')) { + _multiversion_add_workspace_field_in_url_alias_table(TRUE); + } } /** @@ -94,7 +96,7 @@ function multiversion_update_8001() { $connection = Database::getConnection(); if ($connection instanceof Connection) { $schema = $connection->schema(); - $entity_manager = \Drupal::service('entity.manager'); + $entity_manager = \Drupal::service('entity_type.manager'); $manager = \Drupal::service('multiversion.manager'); // Find all supported entities. @@ -583,7 +585,9 @@ function multiversion_update_8107() { * Add workspace field in url_alias table. */ function multiversion_update_8108() { - _multiversion_add_workspace_field_in_url_alias_table(); + if (version_compare(\Drupal::VERSION, '8.8', '<')) { + _multiversion_add_workspace_field_in_url_alias_table(); + } } /** @@ -648,3 +652,42 @@ function multiversion_update_8110() { function multiversion_update_8111() { _multiversion_update_uuid_fields(); } + +/** + * Enable path_alias entity type. + */ +function multiversion_update_8112() { + if (\Drupal::moduleHandler()->moduleExists('path_alias')) { + $entity_type_id = 'path_alias'; + $update_manager = \Drupal::entityDefinitionUpdateManager(); + // Get the current path_alias entity type definition, ensure the storage schema + // class is set. + $entity_type = $update_manager->getEntityType($entity_type_id) + ->setHandlerClass('storage_schema', PathAliasStorage::class); + // Update entity type. + $update_manager->updateEntityType($entity_type); + + if (\Drupal::moduleHandler()->moduleExists('path_alias')) { + $multiversion_settings = \Drupal::configFactory()->getEditable('multiversion.settings'); + $supported_entity_types = $multiversion_settings->get('supported_entity_types') ?: []; + // Check if entity type should be added to the supported entity types list. + if (!in_array($entity_type_id, $supported_entity_types)) { + $supported_entity_types[] = $entity_type_id; + // Add new entity types to the supported entity types list. + $multiversion_settings + ->set('supported_entity_types', $supported_entity_types) + ->save(); + } + $manager = \Drupal::entityTypeManager(); + $entity_types = []; + $entity_type = $manager->getStorage($entity_type_id)->getEntityType(); + if ($entity_type instanceof ContentEntityTypeInterface) { + $entity_types[$entity_type_id] = $entity_type; + } + } + // Enable new entity type. + if (!empty($entity_types)) { + \Drupal::service('multiversion.manager')->enableEntityTypes($entity_types); + } + } +} diff --git a/multiversion.module b/multiversion.module old mode 100644 new mode 100755 index 0da5221..628719a --- a/multiversion.module +++ b/multiversion.module @@ -1,5 +1,6 @@ setHandlerClass('storage', "$namespace\\PathAliasStorage"); + break; + default: // We can only override the storage handler for entity types we know // what to expect of. @@ -474,7 +480,7 @@ function multiversion_element_info_alter(array &$types) { if (!isset($type['#pre_render'])) { $type['#pre_render'] = []; } - $type['#pre_render'][] = 'multiversion_element_pre_render'; + $type['#pre_render'][] = [MultiversionViewBuilder::class, 'preRender']; } } @@ -510,7 +516,7 @@ function multiversion_workspace_uri(WorkspaceInterface $entity) { /** * Implements hook_form_FORM_ID_alter(). */ -function multiversion_form_node_type_edit_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) { +function multiversion_form_node_type_edit_form_alter(&$form, FormStateInterface $form_state) { // Users don't have the option to disable revisions when using Multiversion. // @todo: {@link https://www.drupal.org/node/2597393 See if there's a way // to just disable this particular option.} @@ -520,7 +526,7 @@ function multiversion_form_node_type_edit_form_alter(&$form, \Drupal\Core\Form\F /** * Implements hook_form_alter(). */ -function multiversion_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { +function multiversion_form_alter(&$form, FormStateInterface $form_state, $form_id) { if (isset($form['revision']['#group']) && $form['revision']['#group'] == 'revision_information') { // Users don't have the option to disable revisions when using Multiversion. $form['revision']['#default_value'] = TRUE; @@ -543,7 +549,7 @@ function multiversion_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $f function multiversion_prepare_file_destination($destination) { $dirname = \Drupal::service('file_system')->dirname($destination); - return file_prepare_directory($dirname, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY); + return \Drupal::service('file_system')->prepareDirectory($dirname, FileSystemInterface::MODIFY_PERMISSIONS | FileSystemInterface::CREATE_DIRECTORY); } /** diff --git a/multiversion.services.yml b/multiversion.services.yml old mode 100644 new mode 100755 index d41299e..e7d4851 --- a/multiversion.services.yml +++ b/multiversion.services.yml @@ -46,7 +46,7 @@ services: arguments: ['@database'] multiversion.manager: class: Drupal\multiversion\MultiversionManager - arguments: ['@workspace.manager', '@serializer', '@entity.manager', '@state', '@language_manager', '@cache.discovery', '@database', '@entity_field.manager', '@event_dispatcher'] + arguments: ['@workspace.manager', '@serializer', '@entity_type.manager', '@state', '@language_manager', '@cache.discovery', '@database', '@entity_field.manager', '@event_dispatcher'] calls: - [setContainer, ['@service_container']] workspace.manager: @@ -95,7 +95,7 @@ services: - { name: workspace_negotiator, priority: 100 } workspace.negotiator.session: class: Drupal\multiversion\Workspace\SessionWorkspaceNegotiator - arguments: ['@user.private_tempstore'] + arguments: ['@tempstore.private'] calls: - [setContainer, ['@service_container']] - [setCurrentUser, ['@current_user']] @@ -111,13 +111,19 @@ services: tags: - { name: normalizer, priority: 50 } multiversion.alias_storage: - decorates: 'path.alias_storage' + decorates: 'path_alias.repository' class: Drupal\multiversion\AliasStorage arguments: ['@database', '@module_handler', '@workspace.manager', '@entity_type.manager', '@state'] public: false decoration_priority: 50 tags: - { name: backend_overridable } + multiversion.alias_repository: + class: Drupal\multiversion\AliasRepository + arguments: ['@database', '@workspace.manager'] + public: false + tags: + - { name: backend_overridable } # The decorated service must remain public in order to not break views # (de-)serialization. # See https://www.drupal.org/project/multiversion/issues/2973609 diff --git a/src/AliasStorage.php b/src/AliasStorage.php old mode 100644 new mode 100755 index 647c019..782856b --- a/src/AliasStorage.php +++ b/src/AliasStorage.php @@ -9,7 +9,8 @@ use Drupal\Core\Database\Query\Merge; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageInterface; -use Drupal\Core\Path\AliasStorage as CoreAliasStorage; +#use Drupal\Core\Path\AliasStorage as CoreAliasStorage; +use Drupal\path_alias\PathAliasStorage as CoreAliasStorage; use Drupal\Core\State\StateInterface; use Drupal\Core\Url; use Drupal\multiversion\Entity\Storage\ContentEntityStorageInterface; @@ -43,7 +44,8 @@ class AliasStorage extends CoreAliasStorage { /** * {@inheritdoc} */ - public function __construct(Connection $connection, ModuleHandlerInterface $module_handler, WorkspaceManagerInterface $workspace_manager, EntityTypeManagerInterface $entity_type_manager, StateInterface $state) { + public function __construct(Connection $connection, ModuleHandlerInterface $module_handler, WorkspaceManagerInterface $workspace_manager, + EntityTypeManagerInterface $entity_type_manager, StateInterface $state) { parent::__construct($connection, $module_handler); $this->workspaceManager = $workspace_manager; $this->entityTypeManager = $entity_type_manager; @@ -53,16 +55,17 @@ class AliasStorage extends CoreAliasStorage { /** * {@inheritdoc} */ - public function save($source, $alias, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $pid = NULL) { + #public function save($source, $alias, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $pid = NULL) { + public function save($entityTypeManager) { if (!$this->connection->schema()->fieldExists('url_alias', 'workspace')) { - return parent::save($source, $alias, $langcode, $pid); + return parent::save($entityTypeManager); } - if ($source[0] !== '/') { + if ($entityTypeManager->getPath()[0] !== '/') { throw new \InvalidArgumentException(sprintf('Source path %s has to start with a slash.', $source)); } - if ($alias[0] !== '/') { + if ($entityTypeManager->getAlias()[0] !== '/') { throw new \InvalidArgumentException(sprintf('Alias path %s has to start with a slash.', $alias)); } @@ -87,9 +90,9 @@ class AliasStorage extends CoreAliasStorage { } $fields = [ - 'source' => $source, - 'alias' => $alias, - 'langcode' => $langcode, + 'source' => $entityTypeManager->getPath(), + 'alias' => $entityTypeManager->getAlias(), + 'langcode' => $entityTypeManager->language()->getId(), 'workspace' => $workspace, ]; diff --git a/src/CommentStatistics.php b/src/CommentStatistics.php old mode 100644 new mode 100755 index e41ca5d..14c7395 --- a/src/CommentStatistics.php +++ b/src/CommentStatistics.php @@ -92,7 +92,7 @@ class CommentStatistics extends CoreCommentStatistics { 'comment_count' => 0, // Use the created date of the entity if it's set, or default to // REQUEST_TIME. - 'last_comment_timestamp' => ($entity instanceof EntityChangedInterface) ? $entity->getChangedTimeAcrossTranslations() : REQUEST_TIME, + 'last_comment_timestamp' => ($entity instanceof EntityChangedInterface) ? $entity->getChangedTimeAcrossTranslations() : \Drupal::time()->getRequestTime(), 'last_comment_name' => '', 'last_comment_uid' => $last_comment_uid, ]) diff --git a/src/Controller/MultiversionNodeController.php b/src/Controller/MultiversionNodeController.php old mode 100644 new mode 100755 index d1b992d..8fc37e6 --- a/src/Controller/MultiversionNodeController.php +++ b/src/Controller/MultiversionNodeController.php @@ -2,6 +2,7 @@ namespace Drupal\multiversion\Controller; +use Drupal\Core\Link; use Drupal\Component\Utility\Xss; use Drupal\Core\Url; use Drupal\node\Controller\NodeController; @@ -21,7 +22,7 @@ class MultiversionNodeController extends NodeController { $langname = $node->language()->getName(); $languages = $node->getTranslationLanguages(); $has_translations = (count($languages) > 1); - $node_storage = $this->entityManager()->getStorage('node'); + $node_storage = $this->EntityTypeManager()->getStorage('node'); $type = $node->getType(); $build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $node->label()]) : $this->t('Revisions for %title', ['%title' => $node->label()]); @@ -53,10 +54,14 @@ class MultiversionNodeController extends NodeController { // this case. $is_current_revision = $vid == $default_revision || (!$current_revision_displayed && $revision->wasDefaultRevision()); if (!$is_current_revision) { - $link = $this->l($date, new Url('entity.node.revision', ['node' => $node->id(), 'node_revision' => $vid])); + // TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes. + // Please manually remove the `use LinkGeneratorTrait;` statement from this class. + $link = Link::fromTextAndUrl($date, new Url('entity.node.revision', ['node' => $node->id(), 'node_revision' => $vid])); } else { - $link = $node->link($date); + // TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes. + // Please confirm that `$node` is an instance of `\Drupal\Core\Entity\EntityInterface`. Only the method name and not the class name was checked for this replacement, so this may be a false positive. + $link = $node->toLink($date)->toString(); $current_revision_displayed = TRUE; } diff --git a/src/Entity/Storage/ContentEntityStorageTrait.php b/src/Entity/Storage/ContentEntityStorageTrait.php old mode 100644 new mode 100755 index 7ba19a8..19f1def --- a/src/Entity/Storage/ContentEntityStorageTrait.php +++ b/src/Entity/Storage/ContentEntityStorageTrait.php @@ -42,7 +42,7 @@ trait ContentEntityStorageTrait { */ public function getOriginalStorage() { if ($this->originalStorage == NULL) { - $this->originalStorage = $this->entityManager->getHandler($this->entityTypeId, 'original_storage'); + $this->originalStorage = $this->entityTypeManager->getHandler($this->entityTypeId, 'original_storage'); } return $this->originalStorage; } diff --git a/src/Entity/Storage/Sql/NodeStorage.php b/src/Entity/Storage/Sql/NodeStorage.php old mode 100644 new mode 100755 index f4b73bb..793ddf0 --- a/src/Entity/Storage/Sql/NodeStorage.php +++ b/src/Entity/Storage/Sql/NodeStorage.php @@ -5,13 +5,18 @@ namespace Drupal\multiversion\Entity\Storage\Sql; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Entity\EntityFieldManager; use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\multiversion\Entity\Storage\ContentEntityStorageInterface; use Drupal\multiversion\Entity\Storage\ContentEntityStorageTrait; use Drupal\node\NodeStorage as CoreNodeStorage; use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Cache\MemoryCache; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; +use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface; /** * Storage handler for nodes. @@ -30,9 +35,12 @@ class NodeStorage extends CoreNodeStorage implements ContentEntityStorageInterfa return new static( $entity_type, $container->get('database'), - $container->get('entity.manager'), + $container->get('entity_field.manager'), $container->get('cache.entity'), $container->get('language_manager'), + $container->get('entity.memory_cache'), + $container->get('entity_type.bundle.info'), + $container->get('entity_type.manager'), $container->get('module_handler') ); } @@ -40,8 +48,11 @@ class NodeStorage extends CoreNodeStorage implements ContentEntityStorageInterfa /** * {@inheritdoc} */ - public function __construct(EntityTypeInterface $entity_type, Connection $database, EntityManagerInterface $entity_manager, CacheBackendInterface $cache, LanguageManagerInterface $language_manager, ModuleHandler $module_handler) { - parent::__construct($entity_type, $database, $entity_manager, $cache, $language_manager); + public function __construct(EntityTypeInterface $entity_type, Connection $database, EntityFieldManager $entity_field_manager, + CacheBackendInterface $cache, LanguageManagerInterface $language_manager, MemoryCacheInterface $memory_cache, EntityTypeBundleInfoInterface $entity_type_bundle_info, + EntityTypeManagerInterface $entity_type_manager, ModuleHandler $module_handler) { + #public function __construct(EntityTypeInterface $entity_type, Connection $database, EntityFieldManager $entity_manager, CacheBackendInterface $cache, LanguageManagerInterface $language_manager, ModuleHandler $module_handler) { + parent::__construct($entity_type, $database, $entity_field_manager, $cache, $language_manager, $memory_cache, $entity_type_bundle_info, $entity_type_manager); $this->moduleHandler = $module_handler; } @@ -83,7 +94,7 @@ class NodeStorage extends CoreNodeStorage implements ContentEntityStorageInterfa public function truncate() { $this->truncateEntityTables(); /* @var \Drupal\node\NodeAccessControlHandlerInterface $access_control_handler */ - $access_control_handler = $this->entityManager->getAccessControlHandler('node'); + $access_control_handler = $this->entity_type_manager->getAccessControlHandler('node'); $access_control_handler->deleteGrants(); } diff --git a/src/MultiversionServiceProvider.php b/src/MultiversionServiceProvider.php old mode 100644 new mode 100755 index 5696ed7..42c8c3a --- a/src/MultiversionServiceProvider.php +++ b/src/MultiversionServiceProvider.php @@ -50,6 +50,17 @@ class MultiversionServiceProvider extends ServiceProviderBase { catch (InvalidArgumentException $e) { // Do nothing, Node module is not installed. } + + try { + $definition = $container->getDefinition('multiversion.alias_repository'); + if (version_compare(\Drupal::VERSION, '8.8', '>=') && + class_exists('Drupal\path_alias\AliasRepository')) { + $definition->setDecoratedService('path_alias.repository', NULL, 50); + } + } + catch (InvalidArgumentException $e) { + // @TODO: Perhaps, do something better than nothing + } } } diff --git a/src/Plugin/migrate/destination/EntityContentBase.php b/src/Plugin/migrate/destination/EntityContentBase.php old mode 100644 new mode 100755 index 1ac2106..8bd0e99 --- a/src/Plugin/migrate/destination/EntityContentBase.php +++ b/src/Plugin/migrate/destination/EntityContentBase.php @@ -42,9 +42,9 @@ class EntityContentBase extends CoreEntityContentBase { $plugin_id, $plugin_definition, $migration, - $container->get('entity.manager')->getStorage($entity_type_id), - array_keys($container->get('entity.manager')->getBundleInfo($entity_type_id)), - $container->get('entity.manager'), + $container->get('entity_type.manager')->getStorage($entity_type_id), + array_keys($container->get('entity_type.manager')->getBundleInfo($entity_type_id)), + $container->get('entity_type.manager'), $container->get('plugin.manager.field.field_type'), $container->get('password') ); @@ -102,7 +102,7 @@ class EntityContentBase extends CoreEntityContentBase { protected function getDefinitionFromEntity($key) { $entity_type_id = $this->storage->getEntityTypeId(); /** @var \Drupal\Core\Field\FieldStorageDefinitionInterface[] $definitions */ - $definitions = $this->entityManager->getBaseFieldDefinitions($entity_type_id); + $definitions = $this->entity_manager->getBaseFieldDefinitions($entity_type_id); $field_definition = $definitions[$key]; return [ diff --git a/src/Plugin/migrate/destination/TempStore.php b/src/Plugin/migrate/destination/TempStore.php old mode 100644 new mode 100755 index 504ba29..742ec46 --- a/src/Plugin/migrate/destination/TempStore.php +++ b/src/Plugin/migrate/destination/TempStore.php @@ -57,7 +57,7 @@ class TempStore extends DestinationBase implements ContainerFactoryPluginInterfa $plugin_id, $plugin_definition, $migration, - $container->get('entity.manager'), + $container->get('entity_type.manager'), $container->get('keyvalue.expirable') ); } diff --git a/src/Plugin/migrate/source/SourcePluginBase.php b/src/Plugin/migrate/source/SourcePluginBase.php old mode 100644 new mode 100755 index 292f09e..173d6b3 --- a/src/Plugin/migrate/source/SourcePluginBase.php +++ b/src/Plugin/migrate/source/SourcePluginBase.php @@ -33,13 +33,13 @@ abstract class SourcePluginBase extends CoreSourcePluginBase implements Containe /** * {@inheritdoc} */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL, EntityManagerInterface $entity_manager) { return new static( $configuration, $plugin_id, $plugin_definition, $migration, - $container->get('entity.manager') + $container->get('entity_type.manager') ); } diff --git a/src/Plugin/migrate/source/TempStore.php b/src/Plugin/migrate/source/TempStore.php old mode 100644 new mode 100755 index aadd171..15e4159 --- a/src/Plugin/migrate/source/TempStore.php +++ b/src/Plugin/migrate/source/TempStore.php @@ -31,7 +31,7 @@ class TempStore extends SourcePluginBase { $plugin_id, $plugin_definition, $migration, - $container->get('entity.manager'), + $container->get('entity_type.manager'), $container->get('keyvalue.expirable') ); } diff --git a/src/Redirect/RedirectRepository.php b/src/Redirect/RedirectRepository.php old mode 100644 new mode 100755 index 831628e..87a15d4 --- a/src/Redirect/RedirectRepository.php +++ b/src/Redirect/RedirectRepository.php @@ -4,7 +4,7 @@ namespace Drupal\multiversion\Redirect; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Database\Connection; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Language\Language; use Drupal\Core\State\StateInterface; use Drupal\multiversion\Workspace\WorkspaceManagerInterface; @@ -29,7 +29,7 @@ class RedirectRepository extends ContribRedirectRepository { /** * {@inheritdoc} */ - public function __construct(EntityManagerInterface $manager, Connection $connection, ConfigFactoryInterface $config_factory, WorkspaceManagerInterface $workspace_manager, StateInterface $state) { + public function __construct(EntityTypeManagerInterface $manager, Connection $connection, ConfigFactoryInterface $config_factory, WorkspaceManagerInterface $workspace_manager, StateInterface $state) { parent::__construct($manager, $connection, $config_factory); $this->workspaceManager = $workspace_manager; $this->state = $state; diff --git a/src/Workspace/SessionWorkspaceNegotiator.php b/src/Workspace/SessionWorkspaceNegotiator.php old mode 100644 new mode 100755 index 1b4b627..10731fc --- a/src/Workspace/SessionWorkspaceNegotiator.php +++ b/src/Workspace/SessionWorkspaceNegotiator.php @@ -3,7 +3,8 @@ namespace Drupal\multiversion\Workspace; use Drupal\multiversion\Entity\WorkspaceInterface; -use Drupal\user\PrivateTempStoreFactory; +#use Drupal\user\PrivateTempStoreFactory; +use Drupal\Core\TempStore\PrivateTempStoreFactory; use Symfony\Component\HttpFoundation\Request; class SessionWorkspaceNegotiator extends WorkspaceNegotiatorBase { diff --git a/tests/modules/multiversion_test_paragraphs/multiversion_test_paragraphs.info.yml b/tests/modules/multiversion_test_paragraphs/multiversion_test_paragraphs.info.yml old mode 100644 new mode 100755 index e12f0ec..5b56bd9 --- a/tests/modules/multiversion_test_paragraphs/multiversion_test_paragraphs.info.yml +++ b/tests/modules/multiversion_test_paragraphs/multiversion_test_paragraphs.info.yml @@ -3,8 +3,8 @@ type: module description: 'Provides default node type and paragraph type for testing.' package: Testing version: VERSION -core: 8.x +core_version_requirement: ^8 || ^9 dependencies: - multiversion - node - - language + - language \ No newline at end of file diff --git a/tests/modules/multiversion_test_views/multiversion_test_views.info.yml b/tests/modules/multiversion_test_views/multiversion_test_views.info.yml old mode 100644 new mode 100755 index 90eb69e..c71e990 --- a/tests/modules/multiversion_test_views/multiversion_test_views.info.yml +++ b/tests/modules/multiversion_test_views/multiversion_test_views.info.yml @@ -3,10 +3,10 @@ type: module description: 'Provides default views for views multiversion tests.' package: Testing version: VERSION -core: 8.x +core_version_requirement: ^8 || ^9 dependencies: - multiversion - node - comment - views - - language + - language \ No newline at end of file diff --git a/tests/src/Functional/CommentStatisticsTest.php b/tests/src/Functional/CommentStatisticsTest.php old mode 100644 new mode 100755 index e908afa..2676193 --- a/tests/src/Functional/CommentStatisticsTest.php +++ b/tests/src/Functional/CommentStatisticsTest.php @@ -66,7 +66,7 @@ class CommentStatisticsTest extends MultiversionFunctionalTestBase { * Tests the node comment statistics. */ function testCommentNodeCommentStatistics() { - $node_storage = $this->container->get('entity.manager')->getStorage('node'); + $node_storage = $this->container->get('entity_type.manager')->getStorage('node'); $this->drupalGet(''); $this->assertNoLink(t('1 comment')); $this->assertEqual($this->node->get('comment')->comment_count, 0, 'The number of comments for the node is correct (0 comments)'); diff --git a/tests/src/Functional/PathAliasTest.php b/tests/src/Functional/PathAliasTest.php old mode 100644 new mode 100755 index bae7fb2..8fe997c --- a/tests/src/Functional/PathAliasTest.php +++ b/tests/src/Functional/PathAliasTest.php @@ -17,7 +17,7 @@ class PathAliasTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected static $modules = ['system', 'path', 'multiversion', 'key_value', 'serialization', 'user', 'node']; + protected static $modules = ['system', 'path_alias', 'multiversion', 'key_value', 'serialization', 'user', 'node']; /** * {@inheritdoc} @@ -39,8 +39,8 @@ class PathAliasTest extends BrowserTestBase { * Test creating, loading, updating and deleting aliases. */ public function testPathAlias() { - /** @var \Drupal\Core\Path\AliasStorageInterface $alias_storage */ - $alias_storage = \Drupal::service('path.alias_storage'); + /** @var \Drupal\multiversion\AliasRepository $alias_repository */ + $alias_repository = \Drupal::service('path_alias.repository'); // Create a test workspace type. WorkspaceType::create([ @@ -71,22 +71,22 @@ class PathAliasTest extends BrowserTestBase { $node1->save(); $this->assertEquals($alias, $node1->get('path')->alias); - $stored_alias = $alias_storage->lookupPathAlias('/' . $node1->toUrl()->getInternalPath(), $node1->language()->getId()); - $this->assertEquals($alias, $stored_alias); + $stored_path = $alias_repository->lookupBySystemPath('/' . $node1->toUrl()->getInternalPath(), $node1->language()->getId()); + $this->assertEquals($alias, $stored_path['alias']); // Set stage as the active workspace. \Drupal::service('workspace.manager')->setActiveWorkspace($stage); - $stored_alias = $alias_storage->lookupPathAlias('/' . $node1->toUrl()->getInternalPath(), $node1->language()->getId()); - $this->assertFalse($stored_alias); + $stored_path = $alias_repository->lookupBySystemPath('/' . $node1->toUrl()->getInternalPath(), $node1->language()->getId()); + $this->assertNull($stored_path); // Create a new node on stage workspace with the same alias. $node2 = $this->drupalCreateNode(); $node2->get('path')->alias = $alias; $node2->save(); $this->assertEquals($alias, $node2->get('path')->alias); - $stored_alias = $alias_storage->lookupPathAlias('/' . $node2->toUrl()->getInternalPath(), $node2->language()->getId()); - $this->assertEquals($alias, $stored_alias); + $stored_path = $alias_repository->lookupBySystemPath('/' . $node2->toUrl()->getInternalPath(), $node2->language()->getId()); + $this->assertEquals($alias, $stored_path['alias']); $this->drupalGet($alias); $web_assert = $this->assertSession(); @@ -136,13 +136,13 @@ class PathAliasTest extends BrowserTestBase { $web_assert->pageTextNotContains('/node/' . $node1->id()); $web_assert->pageTextContains('/node/' . $node2->id()); - //Set a new alias for node2. + // Set a new alias for node2. $alias2 = '/bar'; $node2->get('path')->alias = $alias2; $node2->save(); $this->assertEquals($alias2, $node2->get('path')->alias); - $stored_alias = $alias_storage->lookupPathAlias('/' . $node2->toUrl()->getInternalPath(), $node2->language()->getId()); - $this->assertEquals($alias2, $stored_alias); + $stored_path = $alias_repository->lookupBySystemPath('/' . $node2->toUrl()->getInternalPath(), $node2->language()->getId()); + $this->assertEquals($alias2, $stored_path['alias']); $this->drupalGet('admin/config/search/path'); $web_assert->statusCodeEquals(200); @@ -153,8 +153,8 @@ class PathAliasTest extends BrowserTestBase { $session = $this->getSession(); $page = $session->getPage(); $page->clickLink('Delete'); - $web_assert->pageTextContains('Are you sure you want to delete path alias ' . $alias2 . '?'); - $page->pressButton('Confirm'); + $web_assert->pageTextContains('Are you sure you want to delete the URL alias ' . $alias2 . '?'); + $page->pressButton('Delete'); $this->drupalGet($alias2); $web_assert = $this->assertSession(); @@ -164,15 +164,15 @@ class PathAliasTest extends BrowserTestBase { $web_assert->statusCodeEquals(200); $web_assert->pageTextNotContains('/node/' . $node2->id()); $web_assert->pageTextNotContains('/node/' . $node1->id()); - $stored_alias = $alias_storage->lookupPathAlias('/' . $node2->toUrl()->getInternalPath(), $node2->language()->getId()); - $this->assertFalse($stored_alias); + $stored_path = $alias_repository->lookupBySystemPath('/' . $node2->toUrl()->getInternalPath(), $node2->language()->getId()); + $this->assertNull($stored_path); // Set live as the active workspace. \Drupal::service('workspace.manager')->setActiveWorkspace($live); - // Add an alias that should be accessible from all workspaces. + // Add an alias on URL aliases page. $alias3 = '/aliases'; $edit = [ - 'source' => '/admin/config/search/path', + 'path' => '/admin/config/search/path', 'alias' => $alias3, ]; $this->drupalPostForm('admin/config/search/path/add', $edit, t('Save')); @@ -180,27 +180,24 @@ class PathAliasTest extends BrowserTestBase { $web_assert->statusCodeEquals(200); $web_assert->pageTextContains($alias3); - // Set stage as the active workspace. \Drupal::service('workspace.manager')->setActiveWorkspace($stage); - $this->drupalGet('admin/config/search/path'); - $web_assert->statusCodeEquals(200); - $web_assert->pageTextContains($alias3); - - // Delete alias3. - $session = $this->getSession(); - $page = $session->getPage(); - $page->clickLink('Delete'); - $web_assert->pageTextContains('Are you sure you want to delete path alias ' . $alias3 . '?'); - $page->pressButton('Confirm'); $this->drupalGet('admin/config/search/path'); $web_assert->statusCodeEquals(200); $web_assert->pageTextNotContains($alias3); - // Set live as the active workspace. + // Go back to Live workspace and delete alias3. \Drupal::service('workspace.manager')->setActiveWorkspace($live); + $this->drupalGet('admin/config/search/path'); + $web_assert->statusCodeEquals(200); + + $session = $this->getSession(); + $page = $session->getPage(); + $page->clickLink('Delete'); + $web_assert->pageTextContains('Are you sure you want to delete the URL alias ' . $alias3 . '?'); + $page->pressButton('Delete'); $this->drupalGet('admin/config/search/path'); $web_assert->statusCodeEquals(200); $web_assert->pageTextNotContains($alias3); diff --git a/tests/src/Functional/SequenceIndexTest.php b/tests/src/Functional/SequenceIndexTest.php old mode 100644 new mode 100755 index 7a04b5e..1b85529 --- a/tests/src/Functional/SequenceIndexTest.php +++ b/tests/src/Functional/SequenceIndexTest.php @@ -58,7 +58,7 @@ class SequenceIndexTest extends MultiversionFunctionalTestBase { $entity = EntityTestRev::create(); $workspace_name = $this->randomMachineName(); /** @var \Drupal\Core\Entity\EntityStorageInterface $workspace_storage */ - $workspace_storage = $this->container->get('entity.manager')->getStorage('workspace'); + $workspace_storage = $this->container->get('entity_type.manager')->getStorage('workspace'); $workspace_storage->create(['machine_name' => $workspace_name, 'type' => 'basic']); // Generate a new sequence ID. $this->sequenceIndex->useWorkspace($workspace_name)->add($entity); diff --git a/tests/src/Functional/UninstallTest.php b/tests/src/Functional/UninstallTest.php old mode 100644 new mode 100755 diff --git a/tests/src/Functional/UuidIndexHooksTest.php b/tests/src/Functional/UuidIndexHooksTest.php old mode 100644 new mode 100755 index ea69f86..670fb70 --- a/tests/src/Functional/UuidIndexHooksTest.php +++ b/tests/src/Functional/UuidIndexHooksTest.php @@ -14,7 +14,7 @@ class UuidIndexHooksTest extends MultiversionFunctionalTestBase { $this->assertTrue(empty($keys), 'Empty array was returned when fetching non-existing UUID.'); /** @var \Drupal\Core\Entity\EntityStorageInterface $entity_test_storage */ - $entity_test_storage = $this->container->get('entity.manager')->getStorage('entity_test'); + $entity_test_storage = $this->container->get('entity_type.manager')->getStorage('entity_test'); $entity = $entity_test_storage->create(); $entity->save(); $keys = $this->uuidIndex->get($entity->uuid()); diff --git a/tests/src/Functional/UuidIndexTest.php b/tests/src/Functional/UuidIndexTest.php old mode 100644 new mode 100755 index c7c4a79..dceb900 --- a/tests/src/Functional/UuidIndexTest.php +++ b/tests/src/Functional/UuidIndexTest.php @@ -82,7 +82,7 @@ class UuidIndexTest extends MultiversionFunctionalTestBase { $this->assertEqual($expected, $entries, 'Multiple entries are correct.'); /** @var \Drupal\Core\Entity\EntityStorageInterface $workspace_storage */ - $workspace_storage = $this->container->get('entity.manager')->getStorage('workspace'); + $workspace_storage = $this->container->get('entity_type.manager')->getStorage('workspace'); // Create new workspaces and query those. $ws1 = $this->randomMachineName(); $workspace_storage->create(['machine_name' => $ws1, 'type' => 'basic']); diff --git a/tests/src/Kernel/EntityLoadingTest.php b/tests/src/Kernel/EntityLoadingTest.php old mode 100644 new mode 100755 index f0c7d7e..a7a34a4 --- a/tests/src/Kernel/EntityLoadingTest.php +++ b/tests/src/Kernel/EntityLoadingTest.php @@ -27,6 +27,7 @@ class EntityLoadingTest extends KernelTestBase { $this->installEntitySchema('workspace'); $this->installEntitySchema('node'); $this->installEntitySchema('user'); + $this->installEntitySchema('path_alias'); $this->installConfig('multiversion'); $this->installSchema('key_value', 'key_value_sorted'); $multiversion_manager = $this->container->get('multiversion.manager'); diff --git a/tests/src/Kernel/MultiversionIndexFactoryTest.php b/tests/src/Kernel/MultiversionIndexFactoryTest.php old mode 100644 new mode 100755 diff --git a/tests/src/Kernel/ParagraphsTest.php b/tests/src/Kernel/ParagraphsTest.php old mode 100644 new mode 100755 index ca28958..b4272c1 --- a/tests/src/Kernel/ParagraphsTest.php +++ b/tests/src/Kernel/ParagraphsTest.php @@ -59,6 +59,7 @@ class ParagraphsTest extends KernelTestBase { $this->installEntitySchema('paragraph'); $this->installEntitySchema('user'); $this->installEntitySchema('workspace'); + $this->installEntitySchema('path_alias'); $this->installConfig(['multiversion', 'multiversion_test_paragraphs']); $this->installSchema('node', 'node_access'); $this->installSchema('key_value', 'key_value_sorted'); diff --git a/tests/src/Kernel/ViewsTest.php b/tests/src/Kernel/ViewsTest.php old mode 100644 new mode 100755 diff --git a/tests/src/Kernel/WorkspaceTest.php b/tests/src/Kernel/WorkspaceTest.php old mode 100644 new mode 100755 index bb9279d..00e3731 --- a/tests/src/Kernel/WorkspaceTest.php +++ b/tests/src/Kernel/WorkspaceTest.php @@ -47,6 +47,7 @@ class WorkspaceTest extends KernelTestBase { $this->installEntitySchema('block_content_type'); $this->installEntitySchema('block_content'); $this->installEntitySchema('menu_link_content'); + $this->installEntitySchema('path_alias'); $this->installConfig('multiversion'); $this->installSchema('key_value', 'key_value_sorted'); $this->installSchema('system', ['sequences', 'key_value_expire']); diff --git a/tests/src/Unit/WorkspaceManagerTest.php b/tests/src/Unit/WorkspaceManagerTest.php old mode 100644 new mode 100755 index 0a1d33a..8423799 --- a/tests/src/Unit/WorkspaceManagerTest.php +++ b/tests/src/Unit/WorkspaceManagerTest.php @@ -115,7 +115,7 @@ class WorkspaceManagerTest extends UnitTestCase { $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); $container = new ContainerBuilder(); - $container->set('entity.manager', $this->entityTypeManager); + $container->set('entity_type.manager', $this->entityTypeManager); $container->set('request_stack', $this->requestStack); $container->setParameter('workspace.default', 1); \Drupal::setContainer($container);