You are here

public function ContentTranslationController::edit in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_translation/src/Controller/ContentTranslationController.php \Drupal\content_translation\Controller\ContentTranslationController::edit()

Builds the edit translation page.

Parameters

\Drupal\Core\Language\LanguageInterface $language: The language of the translated values. Defaults to the current content language.

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match object from which to extract the entity type.

string $entity_type_id: (optional) The entity type ID.

Return value

array A processed form array ready to be rendered.

File

core/modules/content_translation/src/Controller/ContentTranslationController.php, line 415

Class

ContentTranslationController
Base class for entity translation controllers.

Namespace

Drupal\content_translation\Controller

Code

public function edit(LanguageInterface $language, RouteMatchInterface $route_match, $entity_type_id = NULL) {
  $entity = $route_match
    ->getParameter($entity_type_id);

  // @todo Provide a way to figure out the default form operation. Maybe like
  //   $operation = isset($info['default_operation']) ? $info['default_operation'] : 'default';
  //   See https://www.drupal.org/node/2006348.
  // Use the edit form handler, if available, otherwise default.
  $operation = $entity
    ->getEntityType()
    ->hasHandlerClass('form', 'edit') ? 'edit' : 'default';
  $form_state_additions = [];
  $form_state_additions['langcode'] = $language
    ->getId();
  $form_state_additions['content_translation']['translation_form'] = TRUE;
  return $this
    ->entityFormBuilder()
    ->getForm($entity, $operation, $form_state_additions);
}