You are here

private function GoogleAdwordsPathTrackerBackup::_buildPathTree in Google AdWords Conversion Tracking 8

Build the GoogleAdwordsPathConfig path render tree

Return value

array $tree This is in the format of a render tree, with #configs=[ GoogleAdwordsPathConfig ]

1 call to GoogleAdwordsPathTrackerBackup::_buildPathTree()
GoogleAdwordsPathTrackerBackup::buildPathTree in modules/google_adwords_path/src/GoogleAdwordsPathTracker.backup.php
Retrieve the path tree from cache, or ask for it to be rebuild

File

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

Class

GoogleAdwordsPathTrackerBackup
Class GoogleAdwordsPathTracker.

Namespace

Drupal\google_adwords_path

Code

private function _buildPathTree() {

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

  /**
   * @var GoogleAdwordsPathConfig[] $pathConfigs
   */
  $pathConfigs = $path_storage
    ->loadByProperties(array(
    'enabled' => TRUE,
  ));
  $tree = [];
  foreach ($pathConfigs as $pathConfig) {

    /**
     * @todo we have to deal with strings|arrays in the config entity
     *
     * @var string[] $paths
     */
    $paths = $pathConfig
      ->get('paths');
    if (is_string($paths)) {
      $paths = explode("\n", $paths);
    }
    foreach ($paths as $path) {
      static::_buildPathTreeRecursive($pathConfig, $tree, explode('/', $path));
    }
  }
  return $tree;
}