You are here

public function EntityForm::getEntityFromRouteMatch in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::getEntityFromRouteMatch()

Determines which entity will be used by this form from a RouteMatch object.

Parameters

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

string $entity_type_id: The entity type identifier.

Return value

\Drupal\Core\Entity\EntityInterface The entity object as determined from the passed-in route match.

Overrides EntityFormInterface::getEntityFromRouteMatch

2 methods override EntityForm::getEntityFromRouteMatch()
EntityDisplayFormBase::getEntityFromRouteMatch in core/modules/field_ui/src/Form/EntityDisplayFormBase.php
Determines which entity will be used by this form from a RouteMatch object.
FieldStorageConfigEditForm::getEntityFromRouteMatch in core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
Determines which entity will be used by this form from a RouteMatch object.

File

core/lib/Drupal/Core/Entity/EntityForm.php, line 356
Contains \Drupal\Core\Entity\EntityForm.

Class

EntityForm
Base class for entity forms.

Namespace

Drupal\Core\Entity

Code

public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entity_type_id) {
  if ($route_match
    ->getRawParameter($entity_type_id) !== NULL) {
    $entity = $route_match
      ->getParameter($entity_type_id);
  }
  else {
    $entity = $this->entityManager
      ->getStorage($entity_type_id)
      ->create([]);
  }
  return $entity;
}