You are here

protected function EntityTranslationDefaultHandler::findMatchingPathScheme in Entity Translation 7

Find a path scheme matching the given path.

Parameters

$router_path: The path to match against.

Return value

The key of the path scheme if found, FALSE otherwise.

1 call to EntityTranslationDefaultHandler::findMatchingPathScheme()
EntityTranslationDefaultHandler::initPathScheme in includes/translation.handler.inc

File

includes/translation.handler.inc, line 1135
Default translation handler for the translation module.

Class

EntityTranslationDefaultHandler
Class implementing the default entity translation behaviours.

Code

protected function findMatchingPathScheme($router_path) {
  $path_keys = array_flip(array(
    'base path',
    'view path',
    'edit path',
    'translate path',
  ));
  foreach ($this->entityInfo['translation']['entity_translation']['path schemes'] as $delta => $scheme) {

    // Construct regular expression pattern for determining whether any path
    // in the current scheme matches the current request path.
    $path_elements = array_intersect_key($scheme, $path_keys);

    // Add additional path elements which were added during
    // entity_translation_menu_alter().
    if (isset($path_elements['edit path'])) {
      $path_elements[] = $path_elements['edit path'] . '/%entity_translation_language';
      $path_elements[] = $path_elements['edit path'] . '/add/%entity_translation_language/%entity_translation_language';
    }
    if (isset($path_elements['translate path'])) {
      $path_elements[] = $path_elements['translate path'] . '/delete/%entity_translation_language';
    }

    // Replace wildcards with % for matching parameters.
    $path_elements = array_flip(preg_replace('|%[^/]+|', '%', $path_elements));
    if (isset($path_elements[$router_path])) {
      return $delta;
    }
  }
  return FALSE;
}