ProxyClassFinder.php in X Autoload 7.5
File
src/ClassFinder/ProxyClassFinder.php
View source
<?php
namespace Drupal\xautoload\ClassFinder;
use Drupal\xautoload\ClassLoader\AbstractClassLoader;
use Drupal\xautoload\CacheMissObserver\CacheMissObserverInterface;
class ProxyClassFinder extends AbstractClassLoader implements ClassFinderInterface {
protected $finder;
protected $cacheMissObservers = array();
protected $initialized = FALSE;
function __construct($finder) {
$this->finder = $finder;
}
function loadClass($class) {
$this
->initFinder();
$this->finder
->loadClass($class);
}
function apiFindFile($api, $class) {
$this
->initFinder();
return $this->finder
->apiFindFile($api, $class);
}
function observeFirstCacheMiss($observer) {
if (!$this->initialized) {
$this->cacheMissObservers[] = $observer;
}
else {
$observer
->cacheMiss($this->finder);
}
}
function getFinder() {
$this
->initFinder();
return $this->finder;
}
protected function initFinder() {
if (!$this->initialized) {
$this->initialized = TRUE;
foreach ($this->cacheMissObservers as $operation) {
$operation
->cacheMiss($this->finder);
}
}
}
}
Classes
Name |
Description |
ProxyClassFinder |
A placeholder class finder. Used to postpone expensive operations until they
are actually needed. |