You are here

public function FormModeManagerEntityController::getEntityControllerResponse in Form mode manager 8.2

Instantiate correct objects depending entities.

Contain all the logic to use the abstract factory and call, correct entityFormMode object depending entity_type using bundles, or if the entity need to be processed specifically like Taxonomy.

All of children object share EntityFormModeManagerInterface to make sure, methods are used by factory.

Parameters

string $method: Name of the method we need to build.

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

Return value

\Drupal\form_mode_manager\EntityFormModeManagerInterface An instance of correct controller object.

Throws

\Exception Thrown when specified method was not found.

6 calls to FormModeManagerEntityController::getEntityControllerResponse()
FormModeManagerEntityController::addPage in src/Controller/FormModeManagerEntityController.php
Displays add content links for available entity types.
FormModeManagerEntityController::addPageTitle in src/Controller/FormModeManagerEntityController.php
The _title_callback for the entity.add routes.
FormModeManagerEntityController::checkAccess in src/Controller/FormModeManagerEntityController.php
Checks access for the Form Mode Manager routes.
FormModeManagerEntityController::editPageTitle in src/Controller/FormModeManagerEntityController.php
The _title_callback for the entity.add routes.
FormModeManagerEntityController::entityAdd in src/Controller/FormModeManagerEntityController.php
Provides the entity add submission form.

... See full list

File

src/Controller/FormModeManagerEntityController.php, line 194

Class

FormModeManagerEntityController
Generic Controller for entity using form mode manager routing.

Namespace

Drupal\form_mode_manager\Controller

Code

public function getEntityControllerResponse($method, RouteMatchInterface $route_match) {
  $entity_type_id = $route_match
    ->getRouteObject()
    ->getOption('_form_mode_manager_entity_type_id');
  $entity_storage = $this->entityTypeManager
    ->getStorage($entity_type_id);

  // Entities without bundles need to be flagged 'unbundled_entity'.
  $entity_type_id = $this
    ->bundledEntity($entity_storage) ? $entity_type_id : 'unbundled_entity';
  $controller_object = $this
    ->getEntityControllerObject($entity_type_id);
  if (!method_exists($controller_object, $method)) {
    throw new \Exception('Specified ' . $method . ' method not found.');
  }
  return $controller_object
    ->{$method}($route_match);
}