You are here

public function ModerationInformation::isRevisionableBundleForm in Workbench Moderation 8.2

Same name and namespace in other branches
  1. 8 src/ModerationInformation.php \Drupal\workbench_moderation\ModerationInformation::isRevisionableBundleForm()

Determines if the form is the bundle edit of a revisionable entity.

The logic here is not entirely clear, but seems to work. The form- and entity-dereference chaining seems excessive but is what works.

Parameters

\Drupal\Core\Form\FormInterface $form_object: The form definition object for this form.

Return value

bool True if the form is the bundle edit form for an entity type that supports revisions, false otherwise.

Overrides ModerationInformationInterface::isRevisionableBundleForm

File

src/ModerationInformation.php, line 134

Class

ModerationInformation
General service for moderation-related questions about Entity API.

Namespace

Drupal\workbench_moderation

Code

public function isRevisionableBundleForm(FormInterface $form_object) {

  // We really shouldn't be checking for a base class, but core lacks an
  // interface here. When core adds a better way to determine if we're on
  // a Bundle configuration form we should switch to that.
  if ($form_object instanceof BundleEntityFormBase) {
    $bundle_of = $form_object
      ->getEntity()
      ->getEntityType()
      ->getBundleOf();
    $type = $this->entityTypeManager
      ->getDefinition($bundle_of);
    return $type
      ->isRevisionable();
  }
  return FALSE;
}