You are here

protected function HashAutolinker::currentRouteEntity in Markdown 3.0.x

Retrieves an Entity object for the current route.

Return value

\Drupal\Core\Entity\EntityInterface|null An Entity object or NULL if none could be found.

File

src/Plugin/Markdown/Extension/HashAutolinker.php, line 168

Class

HashAutolinker
Plugin annotation @MarkdownExtension( id = "hash_autolinker", label = @Translation("# Autolinker"), installed = TRUE, description = @Translation("Automatically link commonly used references that come after a hash character (#) without having…

Namespace

Drupal\markdown\Plugin\Markdown\Extension

Code

protected function currentRouteEntity() {
  $route_match = \Drupal::routeMatch();
  foreach ($route_match
    ->getParameters()
    ->all() as $item) {
    if ($item instanceof EntityInterface) {
      return $item;
    }
  }
}