You are here

public function CommerceCurrencyResolversRefreshTrait::isAdminPath in Commerce Currency Resolver 8

Detect admin/* paths.

Return value

bool Return true if on admin/ path.

2 calls to CommerceCurrencyResolversRefreshTrait::isAdminPath()
CommerceCurrencyResolver::skipResolvingPrice in src/Resolver/CommerceCurrencyResolver.php
Helper to determine when resolver is active.
CommerceCurrencyResolversRefreshTrait::shouldCurrencyRefresh in src/CommerceCurrencyResolversRefreshTrait.php
Get refresh state based on path.

File

src/CommerceCurrencyResolversRefreshTrait.php, line 28

Class

CommerceCurrencyResolversRefreshTrait
Handle access where currency resolver can refresh order.

Namespace

Drupal\commerce_currency_resolver

Code

public function isAdminPath() {
  $paths =& drupal_static(__FUNCTION__, []);
  $path = \Drupal::requestStack()
    ->getCurrentRequest()
    ->getPathInfo();

  // Compare the lowercase path alias (if any) and internal path.
  // Do not trim a trailing slash if that is the complete path.
  $path = $path === '/' ? $path : rtrim($path, '/');
  if (isset($paths[$path])) {
    return $paths[$path];
  }
  $patterns = '/admin/*';
  $paths[$path] = \Drupal::service('path.matcher')
    ->matchPath($path, $patterns);
  return $paths[$path];
}