function entity_form_controller

Returns an entity form controller for the given operation.

Since there might be different scenarios in which an entity is edited, multiple form controllers suitable to the different operations may be defined. If no controller is found for the default operation, the base class will be used. If a non-existing non-default operation is specified an exception will be thrown.

Parameters

$entity_type: The type of the entity.

$operation: (optional) The name of an operation, such as creation, editing or deletion, identifying the controlled form. Defaults to 'default' which is the usual create/edit form.

Return value

Drupal\Core\Entity\EntityFormControllerInterface An entity form controller instance.

See also

\Drupal\Core\Entity\EntityManager

File

drupal/core/includes/entity.inc, line 426
Entity API for handling entities like nodes or users.

Code

function entity_form_controller($entity_type, $operation = 'default') {
  return Drupal::entityManager()
    ->getFormController($entity_type, $operation);
}