public function PreviewLinkForm::getEntityFromRouteMatch in Preview Link 8
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/
Form/ PreviewLinkForm.php, line 84
Class
- PreviewLinkForm
- Preview link form.
Namespace
Drupal\preview_link\FormCode
public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entity_type_id) {
/** @var \Drupal\preview_link\PreviewLinkStorageInterface $storage */
$storage = $this->entityTypeManager
->getStorage('preview_link');
$related_entity = $this
->getRelatedEntity();
if (!($preview_link = $storage
->getPreviewLink($related_entity))) {
$preview_link = $storage
->createPreviewLinkForEntity($related_entity);
}
return $preview_link;
}