class MockContainerAware
Same name in this branch
- 10 core/tests/Drupal/Tests/Core/Utility/CallableResolverTest.php \Drupal\Tests\Core\Utility\MockContainerAware
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php \Drupal\Tests\Core\Controller\MockContainerAware
- 8.9.x core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php \Drupal\Tests\Core\Controller\MockContainerAware
Hierarchy
- class \Drupal\Tests\Core\Controller\MockContainerAware implements \Symfony\Component\DependencyInjection\ContainerAwareInterface
Expanded class hierarchy of MockContainerAware
File
-
core/
tests/ Drupal/ Tests/ Core/ Controller/ ControllerResolverTest.php, line 235
Namespace
Drupal\Tests\Core\ControllerView source
class MockContainerAware implements ContainerAwareInterface {
/**
* The service container.
*/
protected ContainerInterface $container;
/**
* Sets the service container.
*/
public function setContainer(?ContainerInterface $container) : void {
$this->container = $container;
}
public function getResult() {
if (empty($this->container)) {
throw new \Exception('Container was not injected.');
}
return 'This is container aware.';
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
MockContainerAware::$container | protected | property | The service container. |
MockContainerAware::getResult | public | function | |
MockContainerAware::setContainer | public | function | Sets the service container. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.