diff core/modules/content_moderation/src/ModerationInformation.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
line wrap: on
line diff
--- a/core/modules/content_moderation/src/ModerationInformation.php	Thu Feb 28 13:11:55 2019 +0000
+++ b/core/modules/content_moderation/src/ModerationInformation.php	Thu May 09 15:34:47 2019 +0100
@@ -59,6 +59,14 @@
   /**
    * {@inheritdoc}
    */
+  public function isModeratedEntityType(EntityTypeInterface $entity_type) {
+    $bundles = $this->bundleInfo->getBundleInfo($entity_type->id());
+    return !empty(array_column($bundles, 'workflow'));
+  }
+
+  /**
+   * {@inheritdoc}
+   */
   public function canModerateEntitiesOfEntityType(EntityTypeInterface $entity_type) {
     return $entity_type->hasHandlerClass('moderation');
   }
@@ -206,10 +214,17 @@
    * {@inheritdoc}
    */
   public function getWorkflowForEntity(ContentEntityInterface $entity) {
-    $bundles = $this->bundleInfo->getBundleInfo($entity->getEntityTypeId());
-    if (isset($bundles[$entity->bundle()]['workflow'])) {
-      return $this->entityTypeManager->getStorage('workflow')->load($bundles[$entity->bundle()]['workflow']);
-    };
+    return $this->getWorkflowForEntityTypeAndBundle($entity->getEntityTypeId(), $entity->bundle());
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getWorkflowForEntityTypeAndBundle($entity_type_id, $bundle_id) {
+    $bundles = $this->bundleInfo->getBundleInfo($entity_type_id);
+    if (isset($bundles[$bundle_id]['workflow'])) {
+      return $this->entityTypeManager->getStorage('workflow')->load($bundles[$bundle_id]['workflow']);
+    }
     return NULL;
   }