You are here

public function TrailingSlashOutboundPathProcessor::isBundlePathWithTrailingSlash in Trailing Slash 8

Parameters

$path:

Return value

bool

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to TrailingSlashOutboundPathProcessor::isBundlePathWithTrailingSlash()
TrailingSlashOutboundPathProcessor::isPathWithTrailingSlash in src/PathProcessor/TrailingSlashOutboundPathProcessor.php

File

src/PathProcessor/TrailingSlashOutboundPathProcessor.php, line 136

Class

TrailingSlashOutboundPathProcessor
Class TrailingSlashOutboundPathProcessor.

Namespace

Drupal\trailing_slash\PathProcessor

Code

public function isBundlePathWithTrailingSlash($path) {
  $active_bundles = TrailingSlashSettingsHelper::getActiveBundles();
  if (!empty($active_bundles)) {
    $url = Url::fromUri('internal:' . $path);
    try {
      if ($url
        ->isRouted() && ($params = $url
        ->getRouteParameters())) {
        $entity_type = key($params);
        if (array_key_exists($entity_type, $active_bundles)) {
          $entity = $this->entityTypeManager
            ->getStorage($entity_type)
            ->load($params[$entity_type]);
          $bundle = $entity
            ->bundle();
          if (isset($active_bundles[$entity_type][$bundle])) {
            return TRUE;
          }
        }
      }
    } catch (Exception $e) {
    }
  }
  return FALSE;
}