You are here

public function GoogleAdwordsPathTracker::matchPath in Google AdWords Conversion Tracking 8

Try to match a single path to PathCongifs

Parameters

string|array $path:

Return value

\Drupal\google_adwords_path\Entity\GoogleAdwordsPathConfig[]

1 call to GoogleAdwordsPathTracker::matchPath()
GoogleAdwordsPathTracker::matchPaths in modules/google_adwords_path/src/GoogleAdwordsPathTracker.php

File

modules/google_adwords_path/src/GoogleAdwordsPathTracker.php, line 225
Contains Drupal\google_adwords_path\GoogleAdwordsPathTracker.

Class

GoogleAdwordsPathTracker
Class GoogleAdwordsPathTracker.

Namespace

Drupal\google_adwords_path

Code

public function matchPath($path) {

  // convert string paths to arrays
  if (is_string($path)) {
    $path = explode('/', trim($path));
  }

  /**
   * @var array tree of PathConfigs
   *   a tree of path configs organized by path element
   */
  $tree = $this
    ->buildPathTree();

  /**
   * @var array $matches
   *   an array of config_path ids that matched the path
   */
  $matches = self::_matchPath_recursive($tree, $path);

  /**
   * @var \Drupal\Core\Entity\EntityStorageInterface $path_storage
   */
  $path_storage = $this->entity_type_manager
    ->getStorage('google_adwords_path_config');
  return $path_storage
    ->loadMultiple($matches);
}