class LoadClassGetFileInjectedApi in X Autoload 7.4
Same name and namespace in other branches
- 7.5 src/ClassFinder/InjectedApi/LoadClassGetFileInjectedApi.php \Drupal\xautoload\ClassFinder\InjectedApi\LoadClassGetFileInjectedApi
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\FindFileInjectedApi
- class \Drupal\xautoload\ClassFinder\InjectedApi\LoadClassGetFileInjectedApi
- class \Drupal\xautoload\ClassFinder\InjectedApi\FindFileInjectedApi
Expanded class hierarchy of LoadClassGetFileInjectedApi
4 files declare their use of LoadClassGetFileInjectedApi
- ApcClassLoader.php in lib/
ClassLoader/ ApcClassLoader.php - WinCacheClassLoader.php in lib/
ClassLoader/ WinCacheClassLoader.php - xautoload.early.lib.inc in ./
xautoload.early.lib.inc - XCacheClassLoader.php in lib/
ClassLoader/ XCacheClassLoader.php
File
- lib/
ClassFinder/ InjectedApi/ LoadClassGetFileInjectedApi.php, line 12
Namespace
Drupal\xautoload\ClassFinder\InjectedApiView source
class LoadClassGetFileInjectedApi extends FindFileInjectedApi {
/**
* Suggest a file that, if the file exists,
* has to declare the class we are looking for.
* Only keep the class on success.
*
* @param string $file
* The file that is supposed to declare the class.
*
* @return bool
* TRUE, if the file exists.
* FALSE, otherwise.
*/
function suggestFile($file) {
if (file_exists($file)) {
$this->file = $file;
require $file;
return TRUE;
}
else {
return FALSE;
}
}
/**
* Same as suggestFile(), but skip the file_exists(),
* assuming that we already know the file exists.
*
* This could make sense if a plugin already did the file_exists() check.
*
* @param string $file
* The file that is supposed to declare the class.
*
* @return bool
* TRUE, if the file was found - which is always.
*/
function suggestFile_skipFileExists($file) {
$this->file = $file;
require $file;
return TRUE;
}
/**
* Same as suggestFile(), but assume that file_exists() returns TRUE.
*
* @param string $file
* The file that is supposed to declare the class.
*
* @return bool
* TRUE, if the file was found - which is always.
*/
function suggestFile_checkNothing($file) {
$this->file = $file;
require $file;
return TRUE;
}
/**
* Same as suggestFile(), but check the full PHP include path.
*
* @param string $file
* The file that is supposed to declare the class.
*
* @return bool
* TRUE, if the file exists.
* FALSE, otherwise.
*/
function suggestFile_checkIncludePath($file) {
if (FALSE !== ($file = Util::findFileInIncludePath($file))) {
$this->file = $file;
require $file;
return TRUE;
}
}
/**
* {@inheritdoc}
*/
function guessFile($file) {
require_once $file;
if (Util::classIsDefined($this->className)) {
$this->file = $file;
return TRUE;
}
}
/**
* {@inheritdoc}
*/
function guessPath($file) {
if (file_exists($file)) {
require_once $file;
if (Util::classIsDefined($this->className)) {
$this->file = $file;
return TRUE;
}
}
}
/**
* {@inheritdoc}
*/
function claimFile($file) {
require $file;
$this->file = $file;
return TRUE;
}
/**
* {@inheritdoc}
*/
function claimPath($file) {
if (file_exists($file)) {
require $file;
$this->file = $file;
return TRUE;
}
}
}
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 | ||
FindFileInjectedApi:: |
protected | property | The file that was found. | |
FindFileInjectedApi:: |
function | When the process has finished, use this to return the result. | ||
LoadClassGetFileInjectedApi:: |
function |
Suggest a file that MUST exist, and if so, MUST declare the class we are
looking for. Overrides FindFileInjectedApi:: |
||
LoadClassGetFileInjectedApi:: |
function |
Suggest a file that MAY exist, and if so, MUST declare the class we are
looking for. Overrides FindFileInjectedApi:: |
||
LoadClassGetFileInjectedApi:: |
function |
Suggest a file that MUST exists, and that MAY declare the class we are
looking for. Overrides FindFileInjectedApi:: |
||
LoadClassGetFileInjectedApi:: |
function |
Suggest a file that MAY exist, and that MAY declare the class we are
looking for. Overrides FindFileInjectedApi:: |
||
LoadClassGetFileInjectedApi:: |
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 FindFileInjectedApi:: |
||
LoadClassGetFileInjectedApi:: |
function |
Same as suggestFile(), but check the full PHP include path. Overrides FindFileInjectedApi:: |
||
LoadClassGetFileInjectedApi:: |
function |
Same as suggestFile(), but assume that file_exists() returns TRUE. Overrides FindFileInjectedApi:: |
||
LoadClassGetFileInjectedApi:: |
function |
Same as suggestFile(), but skip the file_exists(),
assuming that we already know the file exists. Overrides FindFileInjectedApi:: |