public static function MockService::getFactoryMethod in Zircon Profile 8.0
Same name and namespace in other branches
- 8 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 1181 - Contains \Drupal\Tests\Component\DependencyInjection\ContainerTest.
Class
- MockService
- Helper class to test Container::get() method.
Namespace
Drupal\Tests\Component\DependencyInjectionCode
public static function getFactoryMethod($class, $arguments = array()) {
$r = new \ReflectionClass($class);
$service = $r
->getConstructor() === NULL ? $r
->newInstance() : $r
->newInstanceArgs($arguments);
return $service;
}