You are here

public function ExtensionNamespaces::registerExtensionPsr4 in X Autoload 7.5

Registers the namespace with PSR-4 for a module even though it might be currently disabled, or even though it might be early in the request.

Parameters

string $__FILE__:

string $subdir:

File

src/Phases/ExtensionNamespaces.php, line 76

Class

ExtensionNamespaces

Namespace

Drupal\xautoload\Phases

Code

public function registerExtensionPsr4($__FILE__, $subdir) {
  if (NULL === $this->finder) {

    // Sleeping..
    $this->queue[$__FILE__] = $subdir;
    return;
  }
  $info = pathinfo($__FILE__);
  $name = $info['filename'];

  // Check if something was registered before.
  if (isset($this->registered[$name])) {
    if ('psr-4' === $this->registered[$name]) {

      // It already happened.
      return;
    }

    // Unregister the lazy plugins.
    $this->finder
      ->getNamespaceMap()
      ->unregisterDeepPath('Drupal/' . $name . '/', $name);
    $this->finder
      ->getPrefixMap()
      ->unregisterDeepPath(str_replace('_', '/', $name) . '/', $name);
  }
  $this
    ->_registerExtensionPsr4($name, $info['dirname'], $subdir);
}