You are here

public function UserFormModeController::entityEdit in Form mode manager 8

Provides the entity 'edit' form.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.

Return value

array The entity edit Form.

Overrides EntityFormModeBase::entityEdit

File

src/Controller/UserFormModeController.php, line 57

Class

UserFormModeController
Controller for specific User entity form mode support.

Namespace

Drupal\form_mode_manager\Controller

Code

public function entityEdit(RouteMatchInterface $route_match) {

  /* @var \Drupal\Core\Entity\EntityInterface $entity */
  $entity = $this
    ->getEntityFromRouteMatch($route_match);
  $form_mode_id = $this->formModeManager
    ->getFormModeMachineName($route_match
    ->getRouteObject()
    ->getOption('parameters')['form_mode']['id']);
  $operation = empty($form_mode_id) ? 'register' : 'edit_' . $form_mode_id;
  if ($entity instanceof EntityInterface) {
    return $this
      ->getForm($entity, $operation);
  }
}