You are here

public function UpdateUtils::supportsRevisionBundleDefault in Scheduled Updates 8

Determine if the entity type being update support default revision setting.

For now only nodes are supported.

Parameters

\Drupal\scheduled_updates\ScheduledUpdateTypeInterface $scheduledUpdateType:

Return value

bool

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException

Overrides UpdateUtilsInterface::supportsRevisionBundleDefault

File

src/UpdateUtils.php, line 66

Class

UpdateUtils
Service to determine information about Scheduled Update Types.

Namespace

Drupal\scheduled_updates

Code

public function supportsRevisionBundleDefault(ScheduledUpdateTypeInterface $scheduledUpdateType) {
  if ($type_definition = $this
    ->getUpdateTypeDefinition($scheduledUpdateType)) {
    $bundle_type_id = $type_definition
      ->getBundleEntityType();
    $bundle_class = $this->entityTypeManager
      ->getDefinition($bundle_type_id)
      ->getClass();

    // Core doesn't have a standard method for determining if entities of bundle should have new revisions.
    // This should be updated if an interface is create for this.
    // @todo Check Entity API has a solution for this and also check it's interface.
    if ($this
      ->implementsInterface($bundle_class, [
      'Drupal\\node\\NodeTypeInterface',
    ])) {
      return TRUE;
    }
  }
  return FALSE;
}