function MockService::getFactoryMethod
Same name in other branches
- 9 core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\MockService::getFactoryMethod()
- 10 core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\MockService::getFactoryMethod()
- 11.x core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\MockService::getFactoryMethod()
Provides a factory method to get a service.
Parameters
string $class: The class name of the class to instantiate
array $arguments: (optional) Arguments to pass to the new class.
Return value
object The instantiated service object.
File
-
core/
tests/ Drupal/ Tests/ Component/ DependencyInjection/ ContainerTest.php, line 1179
Class
- MockService
- Helper class to test Container::get() method.
Namespace
Drupal\Tests\Component\DependencyInjectionCode
public static function getFactoryMethod($class, $arguments = []) {
$r = new \ReflectionClass($class);
$service = $r->getConstructor() === NULL ? $r->newInstance() : $r->newInstanceArgs($arguments);
return $service;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.