diff --git a/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php b/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php index 5c1d827bbf..20a88f2224 100644 --- a/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php +++ b/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php @@ -5,6 +5,7 @@ use Drupal\Component\Serialization\Json; use Drupal\content_moderation\ModerationInformationInterface; use Drupal\Core\Access\AccessResult; +use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityPublishedInterface; @@ -57,6 +58,11 @@ class ContentModeration extends WorkflowTypeFormBase implements ContainerFactory protected $moderationInfo; /** + * @var \Drupal\Core\Database\Connection + */ + protected $database; + + /** * Constructs a ContentModeration object. * * @param array $configuration @@ -69,12 +75,15 @@ class ContentModeration extends WorkflowTypeFormBase implements ContainerFactory * The entity type manager. * @param \Drupal\content_moderation\ModerationInformationInterface $moderation_info * Moderation information service. + * @param \Drupal\Core\Database\Connection $database + * The database connection. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, ModerationInformationInterface $moderation_info) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, ModerationInformationInterface $moderation_info, Connection $database) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->entityTypeManager = $entity_type_manager; $this->entityTypeBundleInfo = $entity_type_bundle_info; $this->moderationInfo = $moderation_info; + $this->database = $database; } /** @@ -87,7 +96,8 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_definition, $container->get('entity_type.manager'), $container->get('entity_type.bundle.info'), - $container->get('content_moderation.moderation_information') + $container->get('content_moderation.moderation_information'), + $container->get('database') ); } @@ -134,12 +144,12 @@ public function decorateState(StateInterface $state) { public function deleteState($state_id) { $new_state = $this->configuration['states'][$state_id]['published'] ? 'published' : 'draft'; $content_moderation_state_type = $this->entityTypeManager->getDefinition('content_moderation_state'); - \Drupal::database() + $this->database ->update($content_moderation_state_type->getDataTable()) ->condition('moderation_state', $state_id) ->fields(['moderation_state' => $new_state]) ->execute(); - \Drupal::database() + $this->database ->update($content_moderation_state_type->getRevisionDataTable()) ->condition('moderation_state', $state_id) ->fields(['moderation_state' => $new_state])