public function EntityManager::getFormController

Creates a new form controller instance.

Parameters

string $entity_type: The entity type for this form controller.

string $operation: The name of the operation to use, e.g., 'default'.

Return value

\Drupal\Core\Entity\EntityFormControllerInterface A form controller instance.

File

drupal/core/lib/Drupal/Core/Entity/EntityManager.php, line 183
Contains \Drupal\Core\Entity\EntityManager.

Class

EntityManager
Manages entity type plugin definitions.

Namespace

Drupal\Core\Entity

Code

public function getFormController($entity_type, $operation) {
  if (!isset($this->controllers['form'][$operation][$entity_type])) {
    $class = $this
      ->getControllerClass($entity_type, 'form', $operation);
    if (in_array('Drupal\\Core\\Entity\\EntityControllerInterface', class_implements($class))) {
      $this->controllers['form'][$operation][$entity_type] = $class::createInstance($this->container, $entity_type, $this
        ->getDefinition($entity_type));
      $this->controllers['form'][$operation][$entity_type]
        ->setOperation($operation);
    }
    else {
      $this->controllers['form'][$operation][$entity_type] = new $class($operation);
    }
  }
  return $this->controllers['form'][$operation][$entity_type];
}