You are here

function get_path_enitiy_type in Views URL alias 8.2

Parameters

$path string:

Return value

\Drupal\Core\Entity\EntityInterface

6 calls to get_path_enitiy_type()
views_url_alias_form_path_alias_delete_submit in ./views_url_alias.module
views_url_alias_pathauto_alias_alter in ./views_url_alias.module
Implements hook_pathauto_alias_alter().
views_url_alias_path_delete in ./views_url_alias.module
Respond to a path being deleted.
views_url_alias_path_insert in ./views_url_alias.module
Respond to a path being inserted.
views_url_alias_path_update in ./views_url_alias.module
Respond to a path being updated.

... See full list

File

./views_url_alias.module, line 22
Allows content entity Views to be filtered by path aliases.

Code

function get_path_enitiy_type($path) {

  /** @var Router $router */
  $router = \Drupal::service('router.no_access_checks');
  $result = $router
    ->match($path);

  /** @var Route $route */
  $route = $result['_route_object'];
  $params = $route
    ->getOption('parameters');
  $entity_type = '';
  foreach ($params as $param_name => $param) {
    if (isset($param['type'])) {
      $entity_type = explode(':', $param['type'])[1];
      break;
    }
  }
  return $result[$entity_type];
}