You are here

function xautoload_ServiceFactory::classFinder in X Autoload 7.2

Same name and namespace in other branches
  1. 7.3 lib/ServiceFactory.php \xautoload_ServiceFactory::classFinder()

File

lib/ServiceFactory.php, line 38

Class

xautoload_ServiceFactory

Code

function classFinder($registry) {
  if (version_compare(PHP_VERSION, '5.3') >= 0) {

    // Create the finder with namespace support.
    $finder = new xautoload_ClassFinder_NamespaceOrPrefix();

    // D8-style autoloading.
    $drupal_psr0 = $registry->drupalNamespacePlugin;
    $finder
      ->registerNamespacePlugin('Drupal', $drupal_psr0);
  }
  else {

    // If we are not at PHP 5.3 +, we can't have namespaces support.
    $finder = new xautoload_ClassFinder_Prefix();
  }

  // Register the xautoload-style PHP 5.2 compatibility solution.
  $drupal_prefix = $registry->drupalPrefixPlugin;
  $finder
    ->registerPrefixPlugin('', $drupal_prefix);
  return $finder;
}