You are here

function ApcuClassLoader::loadClass in X Autoload 7.5

Callback for class loading. This will include ("require") the file found.

Parameters

string $class: The class to load.

Overrides AbstractClassLoaderDecorator::loadClass

File

src/ClassLoader/ApcuClassLoader.php, line 20

Class

ApcuClassLoader

Namespace

Drupal\xautoload\ClassLoader

Code

function loadClass($class) {

  // Look if the cache has anything for this class.
  if ($file = \apcu_fetch($this->prefix . $class)) {
    if (is_file($file)) {
      require $file;
      return;
    }
    \apcu_delete($this->prefix . $class);
  }

  // Resolve cache miss.
  $api = new LoadClassGetFileInjectedApi($class);
  if ($this->finder
    ->apiFindFile($api, $class)) {
    \apcu_store($this->prefix . $class, $api
      ->getFile());
  }
}