trait Module in AmazonS3 7.2
Same name in this branch
- 7.2 tests/DrupalAdapter/Module.php \Drupal\amazons3Test\DrupalAdapter\Module
- 7.2 src/DrupalAdapter/Module.php \Drupal\amazons3\DrupalAdapter\Module
Stub for module.inc functions, with a call counter to log each call.
@class Module @package Drupal\amazons3Test\DrupalAdapter @codeCoverageIgnore
Hierarchy
- trait \Drupal\amazons3Test\DrupalAdapter\Module
1 file declares its use of Module
- CompositeFactory.php in tests/
Stub/ CompositeFactory.php
File
- tests/
DrupalAdapter/ Module.php, line 12
Namespace
Drupal\amazons3Test\DrupalAdapterView source
trait Module {
protected $callCount = array();
/**
* @see module_invoke_all()
* @param string $hook
* @return array
*/
public function module_invoke_all($hook) {
$this
->logCall(__FUNCTION__ . ':' . $hook);
return array();
}
/**
* @see drupal_alter()
* @param $type
* @param $data
* @param null $context1
* @param null $context2
* @param null $context3
*/
public function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL, &$context3 = NULL) {
$this
->logCall(__FUNCTION__ . ':' . $type);
}
/**
* Log a function call.
*
* @param string $key
* A string with a function and any context data.
*/
protected function logCall($key) {
if (!isset($this->callCount[$key])) {
$this->callCount[$key] = 0;
}
$this->callCount[$key]++;
}
/**
* Get the call count for a given key.
*
* @param string $key
*
* @return int
* The number of times $key has been called.
*/
public function getCallCount($key) {
if (isset($this->callCount[$key])) {
return $this->callCount[$key];
}
return 0;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Module:: |
protected | property | ||
Module:: |
public | function | ||
Module:: |
public | function | Get the call count for a given key. | |
Module:: |
protected | function | Log a function call. | |
Module:: |
public | function |