class LoadClassInjectedAPI in X Autoload 7.4
Same name and namespace in other branches
- 7.5 src/ClassFinder/InjectedApi/LoadClassInjectedAPI.php \Drupal\xautoload\ClassFinder\InjectedApi\LoadClassInjectedAPI
To help testability, we use an injected API instead of just a return value. The injected API can be mocked to provide a mocked file_exists(), and to monitor all suggested candidates, not just the correct return value.
Hierarchy
- class \Drupal\xautoload\ClassFinder\InjectedApi\AbstractInjectedApi implements InjectedApiInterface
- class \Drupal\xautoload\ClassFinder\InjectedApi\LoadClassInjectedAPI
Expanded class hierarchy of LoadClassInjectedAPI
2 files declare their use of LoadClassInjectedAPI
- GenericPrefixMap.php in lib/
ClassFinder/ GenericPrefixMap.php - xautoload.early.lib.inc in ./
xautoload.early.lib.inc
File
- lib/
ClassFinder/ InjectedApi/ LoadClassInjectedAPI.php, line 12
Namespace
Drupal\xautoload\ClassFinder\InjectedApiView source
class LoadClassInjectedAPI extends AbstractInjectedApi {
/**
* {@inheritdoc}
*/
function suggestFile($file) {
if (file_exists($file)) {
require $file;
return TRUE;
}
else {
return FALSE;
}
}
/**
* {@inheritdoc}
*/
function suggestFile_skipFileExists($file) {
require $file;
return TRUE;
}
/**
* {@inheritdoc}
*/
function suggestFile_checkNothing($file) {
require $file;
return TRUE;
}
/**
* {@inheritdoc}
*/
function suggestFile_checkIncludePath($file) {
if (FALSE !== ($file = Util::findFileInIncludePath($file))) {
require $file;
return TRUE;
}
else {
return FALSE;
}
}
/**
* {@inheritdoc}
*/
function guessFile($file) {
require_once $file;
return Util::classIsDefined($this->className);
}
/**
* {@inheritdoc}
*/
function guessPath($file) {
if (file_exists($file)) {
require_once $file;
return Util::classIsDefined($this->className);
}
else {
return FALSE;
}
}
/**
* {@inheritdoc}
*/
function claimFile($file) {
require $file;
return TRUE;
}
/**
* {@inheritdoc}
*/
function claimPath($file) {
if (file_exists($file)) {
require $file;
return TRUE;
}
else {
return FALSE;
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AbstractInjectedApi:: |
protected | property | The class name to look for. Set in the constructor. | |
AbstractInjectedApi:: |
static | function | Dummy method to force autoloading this class (or an ancestor). | |
AbstractInjectedApi:: |
function |
Get the name of the class we are looking for. Overrides InjectedApiInterface:: |
||
AbstractInjectedApi:: |
function |
This is done in the injected api object, so we can easily provide a mock
implementation. Overrides InjectedApiInterface:: |
||
AbstractInjectedApi:: |
function | 1 | ||
LoadClassInjectedAPI:: |
function |
Suggest a file that MUST exist, and if so, MUST declare the class we are
looking for. Overrides InjectedApiInterface:: |
||
LoadClassInjectedAPI:: |
function |
Suggest a file that MAY exist, and if so, MUST declare the class we are
looking for. Overrides InjectedApiInterface:: |
||
LoadClassInjectedAPI:: |
function |
Suggest a file that MUST exists, and that MAY declare the class we are
looking for. Overrides InjectedApiInterface:: |
||
LoadClassInjectedAPI:: |
function |
Suggest a file that MAY exist, and that MAY declare the class we are
looking for. Overrides InjectedApiInterface:: |
||
LoadClassInjectedAPI:: |
function |
Suggest a file that, if the file exists,
has to declare the class we are looking for.
Only keep the class on success. Overrides InjectedApiInterface:: |
||
LoadClassInjectedAPI:: |
function |
Same as suggestFile(), but check the full PHP include path. Overrides InjectedApiInterface:: |
||
LoadClassInjectedAPI:: |
function |
Same as suggestFile(), but assume that file_exists() returns TRUE. Overrides InjectedApiInterface:: |
||
LoadClassInjectedAPI:: |
function |
Same as suggestFile(), but skip the file_exists(),
assuming that we already know the file exists. Overrides InjectedApiInterface:: |