You are here

function DrupalExtensionAdapter::registerExtensions in X Autoload 7.5

Same name and namespace in other branches
  1. 7.4 lib/Adapter/DrupalExtensionAdapter.php \Drupal\xautoload\Adapter\DrupalExtensionAdapter::registerExtensions()

Register lazy plugins for enabled Drupal modules and themes, assuming that we don't know yet whether they use PSR-0, PEAR-Flat, or none of these.

Parameters

string[] $extensions: An array where the keys are extension names, and the values are extension types like 'module' or 'theme'.

File

src/Adapter/DrupalExtensionAdapter.php, line 101

Class

DrupalExtensionAdapter
Service that knows how to register module namespaces and prefixes into the class loader, and that remembers which modules have already been registered.

Namespace

Drupal\xautoload\Adapter

Code

function registerExtensions(array $extensions) {
  $prefix_map = array();
  $namespace_map = array();
  foreach ($extensions as $name => $type) {
    if (empty($this->namespaceBehaviors[$type])) {

      // Unsupported extension type, e.g. "theme_engine".
      // This can happen if a site was upgraded from Drupal 6.
      // See https://drupal.org/comment/8503979#comment-8503979
      continue;
    }
    if (!empty($this->registered[$name])) {

      // The extension has already been processed.
      continue;
    }
    $namespace_map['Drupal/' . $name . '/'][$name] = $this->namespaceBehaviors[$type];
    $prefix_map[str_replace('_', '/', $name) . '/'][$name] = $this->prefixBehaviors[$type];
    $this->registered[$name] = TRUE;
  }
  $this->namespaceMap
    ->registerDeepPaths($namespace_map);
  $this->prefixMap
    ->registerDeepPaths($prefix_map);
}