diff --git a/paragraphs.module b/paragraphs.module index ca656e0..847acd8 100644 --- a/paragraphs.module +++ b/paragraphs.module @@ -216,34 +216,36 @@ function template_preprocess_paragraph(&$variables) { * * @param \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */ -function multiversion_entity_type_alter(array &$entity_types) { - /** @var \Drupal\multiversion\MultiversionManagerInterface $manager */ - $manager = \Drupal::service('multiversion.manager'); +function paragraphs_entity_type_alter(array &$entity_types) { + if (\Drupal::moduleHandler()->moduleExists('multiversion')) { + /** @var \Drupal\multiversion\MultiversionManagerInterface $manager */ + $manager = \Drupal::service('multiversion.manager'); - foreach ($entity_types as $entity_type) { - if ($manager->isEnabledEntityType($entity_type)) { - // Make all content entity types revisionable. - if (!$entity_type->isRevisionable()) { - // We only need to set the revision key to make an entity type - // revisionable. The table names will be handled by the storage class. - // @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage::initTableLayout - $keys = $entity_type->getKeys(); - $keys['revision'] = 'revision_id'; - $entity_type->set('entity_keys', $keys); - if ($entity_type->getRevisionTable() === null) { - $entity_type->set('revision_table', $entity_type->id() . '_revision'); + foreach ($entity_types as $entity_type) { + if ($manager->isEnabledEntityType($entity_type)) { + // Make all content entity types revisionable. + if (!$entity_type->isRevisionable()) { + // We only need to set the revision key to make an entity type + // revisionable. The table names will be handled by the storage class. + // @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage::initTableLayout + $keys = $entity_type->getKeys(); + $keys['revision'] = 'revision_id'; + $entity_type->set('entity_keys', $keys); + if ($entity_type->getRevisionTable() === null) { + $entity_type->set('revision_table', $entity_type->id() . '_revision'); + } + if ($entity_type->getRevisionDataTable() === null) { + $entity_type->set('revision_data_table', $entity_type->id() . '_field_revision'); + } } - if ($entity_type->getRevisionDataTable() === null) { - $entity_type->set('revision_data_table', $entity_type->id() . '_field_revision'); - } - } - $namespace = 'Drupal\multiversion\Entity\Storage\Sql'; - switch ($entity_type->id()) { - case 'paragraph': - $entity_type->setHandlerClass('storage', "$namespace\\ParagraphsStorage"); - $entity_type->setHandlerClass('storage_schema', "$namespace\\ParagraphsStorageSchema"); - break; + $namespace = 'Drupal\paragraphs\Entity\Storage\Sql'; + switch ($entity_type->id()) { + case 'paragraph': + $entity_type->setHandlerClass('storage', "$namespace\\ParagraphsStorage"); + $entity_type->setHandlerClass('storage_schema', "$namespace\\ParagraphsStorageSchema"); + break; + } } } } diff --git a/src/Entity/Storage/Sql/ParagraphsStorage.php b/src/Entity/Storage/Sql/ParagraphsStorage.php index 80235d1..0451aef 100644 --- a/src/Entity/Storage/Sql/ParagraphsStorage.php +++ b/src/Entity/Storage/Sql/ParagraphsStorage.php @@ -1,6 +1,6 @@