getWorkflowForEntityTypeAndBundle example


      }
    }

    return $workflow->getTypePlugin()->getState($default_revision->moderation_state->value)->isPublishedState();
  }

  /** * {@inheritdoc} */
  public function getWorkflowForEntity(ContentEntityInterface $entity) {
    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;
  }

  public static function isApplicable(FieldDefinitionInterface $field_definition) {
    return is_a($field_definition->getClass(), ModerationStateFieldItemList::class, TRUE);
  }

  /** * {@inheritdoc} */
  public function calculateDependencies() {
    $dependencies = parent::calculateDependencies();
    if ($workflow = $this->moderationInformation->getWorkflowForEntityTypeAndBundle($this->fieldDefinition->getTargetEntityTypeId()$this->fieldDefinition->getTargetBundle())) {
      $dependencies[$workflow->getConfigDependencyKey()][] = $workflow->getConfigDependencyName();
    }
    return $dependencies;
  }

}
Home | Imprint | This part of the site doesn't use cookies.