class MockContainerAware

Same name in this branch
  1. 10 core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php \Drupal\Tests\Core\Controller\MockContainerAware
Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php \Drupal\Tests\Core\Controller\MockContainerAware
  2. 8.9.x core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php \Drupal\Tests\Core\Controller\MockContainerAware

Hierarchy

  • class \Drupal\Tests\Core\Utility\MockContainerAware implements \Symfony\Component\DependencyInjection\ContainerAwareInterface

Expanded class hierarchy of MockContainerAware

File

core/tests/Drupal/Tests/Core/Utility/CallableResolverTest.php, line 254

Namespace

Drupal\Tests\Core\Utility
View 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($suffix) {
        if (empty($this->container)) {
            throw new \Exception('Container was not injected.');
        }
        return __METHOD__ . '+' . $suffix;
    }

}

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.