public function GroupContentTypeForm::getEntityFromRouteMatch in Group 8
Same name and namespace in other branches
- 2.0.x src/Entity/Form/GroupContentTypeForm.php \Drupal\group\Entity\Form\GroupContentTypeForm::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 EntityForm::getEntityFromRouteMatch
File
- src/
Entity/ Form/ GroupContentTypeForm.php, line 159
Class
- GroupContentTypeForm
- Form controller for group content type forms.
Namespace
Drupal\group\Entity\FormCode
public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entity_type_id) {
if ($route_match
->getRawParameter($entity_type_id) !== NULL) {
return $route_match
->getParameter($entity_type_id);
}
// If we are on the create form, we can't extract an entity from the route,
// so we need to create one based on the route parameters.
$values = [];
if ($route_match
->getRawParameter('group_type') !== NULL && $route_match
->getRawParameter('plugin_id') !== NULL) {
$values = [
'group_type' => $route_match
->getRawParameter('group_type'),
'content_plugin' => $route_match
->getRawParameter('plugin_id'),
];
}
return $this->entityTypeManager
->getStorage($entity_type_id)
->create($values);
}