|
@@ -7,12 +7,12 @@ use Drupal\Core\Config\ConfigFactoryInterface;
|
|
|
use Drupal\Core\Entity\EntityInterface;
|
|
|
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
|
|
use Drupal\Core\Entity\FieldableEntityInterface;
|
|
|
-use Drupal\Core\Entity\Query\QueryFactory;
|
|
|
use Drupal\Core\Extension\ModuleHandlerInterface;
|
|
|
use Drupal\Core\Session\AccountInterface;
|
|
|
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
|
|
use Drupal\Core\StringTranslation\TranslationInterface;
|
|
|
use Drupal\field\Entity\FieldConfig;
|
|
|
+use Drupal\field\Entity\FieldStorageConfig;
|
|
|
|
|
|
/**
|
|
|
* Manages entity type plugin definitions.
|
|
@@ -27,13 +27,6 @@ class WorkflowManager implements WorkflowManagerInterface {
|
|
|
*/
|
|
|
protected $entityTypeManager;
|
|
|
|
|
|
- /**
|
|
|
- * The entity query factory.
|
|
|
- *
|
|
|
- * @var \Drupal\Core\Entity\Query\QueryFactory
|
|
|
- */
|
|
|
- protected $queryFactory;
|
|
|
-
|
|
|
/**
|
|
|
* The user settings config object.
|
|
|
*
|
|
@@ -61,20 +54,17 @@ class WorkflowManager implements WorkflowManagerInterface {
|
|
|
*
|
|
|
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
|
|
* The entity_type manager service.
|
|
|
- * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory
|
|
|
- * The entity query factory.
|
|
|
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
|
|
* The config factory.
|
|
|
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
|
|
|
* The string translation service.
|
|
|
- * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
|
|
+ * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
|
|
* The module handler service.
|
|
|
* @param \Drupal\Core\Session\AccountInterface $current_user
|
|
|
* The current user.
|
|
|
*/
|
|
|
- public function __construct(EntityTypeManagerInterface $entity_type_manager, QueryFactory $query_factory, ConfigFactoryInterface $config_factory, TranslationInterface $string_translation, ModuleHandlerInterface $module_handler, AccountInterface $current_user) {
|
|
|
+ public function __construct(EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory, TranslationInterface $string_translation, ModuleHandlerInterface $module_handler, AccountInterface $current_user) {
|
|
|
$this->entityTypeManager = $entity_type_manager;
|
|
|
- $this->queryFactory = $query_factory;
|
|
|
$this->userConfig = $config_factory->get('user.settings');
|
|
|
$this->stringTranslation = $string_translation;
|
|
|
$this->moduleHandler = $module_handler;
|
|
@@ -165,6 +155,7 @@ class WorkflowManager implements WorkflowManagerInterface {
|
|
|
$comment = '';
|
|
|
$old_sid = WorkflowManager::getPreviousStateId($entity, $field_name);
|
|
|
$new_sid = $entity->$field_name->value;
|
|
|
+ $field_info = FieldStorageConfig::loadByName($entity->getEntityTypeId(), $field_name);
|
|
|
if ((!$new_sid) && $wid = $field_info->getSetting('workflow_type')) {
|
|
|
/** @var Workflow $workflow */
|
|
|
$workflow = Workflow::load($wid);
|
|
@@ -309,12 +300,12 @@ class WorkflowManager implements WorkflowManagerInterface {
|
|
|
*/
|
|
|
$uid = $account->id();
|
|
|
$new_uid = 0;
|
|
|
-
|
|
|
- db_update('workflow_transition_history')
|
|
|
+ $database = \Drupal::database();
|
|
|
+ $database->update('workflow_transition_history')
|
|
|
->fields(['uid' => $new_uid])
|
|
|
->condition('uid', $uid, '=')
|
|
|
->execute();
|
|
|
- db_update('workflow_transition_schedule')
|
|
|
+ $database->update('workflow_transition_schedule')
|
|
|
->fields(['uid' => $new_uid])
|
|
|
->condition('uid', $uid, '=')
|
|
|
->execute();
|
|
@@ -405,7 +396,7 @@ class WorkflowManager implements WorkflowManagerInterface {
|
|
|
|
|
|
// Entity is new or in preview or there is no current state. Use previous state.
|
|
|
// (E.g., content was created before adding workflow.)
|
|
|
- if ( !$sid || !empty($entity->isNew()) || !empty($entity->in_preview) ) {
|
|
|
+ if (!$sid || !empty($entity->isNew()) || !empty($entity->in_preview)) {
|
|
|
$sid = self::getPreviousStateId($entity, $field_name);
|
|
|
}
|
|
|
|