You are here

protected function EntityRevisionConverter::isEditFormPage in Workbench Moderation 8

Same name and namespace in other branches
  1. 8.2 src/ParamConverter/EntityRevisionConverter.php \Drupal\workbench_moderation\ParamConverter\EntityRevisionConverter::isEditFormPage()

Determines if a given route is the edit-form for an entity.

Parameters

\Symfony\Component\Routing\Route $route: The route definition.

Return value

bool Returns TRUE if the route is the edit form of an entity, FALSE otherwise.

1 call to EntityRevisionConverter::isEditFormPage()
EntityRevisionConverter::applies in src/ParamConverter/EntityRevisionConverter.php
Determines if the converter applies to a specific route and variable.

File

src/ParamConverter/EntityRevisionConverter.php, line 72

Class

EntityRevisionConverter
Defines a class for making sure the edit-route loads the current draft.

Namespace

Drupal\workbench_moderation\ParamConverter

Code

protected function isEditFormPage(Route $route) {
  if ($default = $route
    ->getDefault('_entity_form')) {

    // If no operation is provided, use 'default'.
    $default .= '.default';
    [
      $entity_type_id,
      $operation,
    ] = explode('.', $default);
    if (!$this->entityTypeManager
      ->hasDefinition($entity_type_id)) {
      return FALSE;
    }
    $entity_type = $this->entityTypeManager
      ->getDefinition($entity_type_id);
    return $operation == 'edit' && $entity_type && $entity_type
      ->isRevisionable();
  }
}