abstract class AbstractInjectedApi in X Autoload 7.4
Same name and namespace in other branches
- 7.5 src/ClassFinder/InjectedApi/AbstractInjectedApi.php \Drupal\xautoload\ClassFinder\InjectedApi\AbstractInjectedApi
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
Expanded class hierarchy of AbstractInjectedApi
File
- lib/
ClassFinder/ InjectedApi/ AbstractInjectedApi.php, line 10
Namespace
Drupal\xautoload\ClassFinder\InjectedApiView source
abstract class AbstractInjectedApi implements InjectedApiInterface {
/**
* @var string
* The class name to look for. Set in the constructor.
*/
protected $className;
/**
* @param $class_name
* Name of the class or interface we are trying to load.
*/
function __construct($class_name) {
$this->className = $class_name;
}
/**
* This is done in the injected api object, so we can easily provide a mock
* implementation.
*/
function is_dir($dir) {
return is_dir($dir);
}
/**
* Get the name of the class we are looking for.
*
* @return string
* The class we are looking for.
*/
function getClass() {
return $this->className;
}
/**
* Dummy method to force autoloading this class (or an ancestor).
*/
static function forceAutoload() {
// Do nothing.
}
}
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 | ||
InjectedApiInterface:: |
function | Suggest a file that MUST exist, and if so, MUST declare the class we are looking for. | 3 | |
InjectedApiInterface:: |
function | Suggest a file that MAY exist, and if so, MUST declare the class we are looking for. | 3 | |
InjectedApiInterface:: |
function | Suggest a file that MUST exists, and that MAY declare the class we are looking for. | 3 | |
InjectedApiInterface:: |
function | Suggest a file that MAY exist, and that MAY declare the class we are looking for. | 3 | |
InjectedApiInterface:: |
function | Suggest a file that, if the file exists, has to declare the class we are looking for. Only keep the class on success. | 3 | |
InjectedApiInterface:: |
function | Same as suggestFile(), but check the full PHP include path. | 3 | |
InjectedApiInterface:: |
function | Same as suggestFile(), but assume that file_exists() returns TRUE. | 3 | |
InjectedApiInterface:: |
function | Same as suggestFile(), but skip the file_exists(), assuming that we already know the file exists. | 3 |