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