class EnvironmentCleanerFactory

Test environment cleaner factory.

We use a factory pattern here so that we can inject the test results database which is not a service (and should not be).

Hierarchy

Expanded class hierarchy of EnvironmentCleanerFactory

1 string reference to 'EnvironmentCleanerFactory'
simpletest.services.yml in core/modules/simpletest/simpletest.services.yml
core/modules/simpletest/simpletest.services.yml
1 service uses EnvironmentCleanerFactory
environment_cleaner_factory in core/modules/simpletest/simpletest.services.yml
Drupal\simpletest\EnvironmentCleanerFactory

File

core/modules/simpletest/src/EnvironmentCleanerFactory.php, line 15

Namespace

Drupal\simpletest
View source
class EnvironmentCleanerFactory {
    
    /**
     * The container.
     *
     * @var \Drupal\Core\DependencyInjection\Container
     */
    protected $container;
    
    /**
     * Construct an environment cleaner factory.
     *
     * @param \Drupal\Core\DependencyInjection\Container $container
     *   The container.
     */
    public function __construct(Container $container) {
        $this->container = $container;
    }
    
    /**
     * Factory method to create the environment cleaner service.
     *
     * @return \Drupal\simpletest\EnvironmentCleanerService
     *   The environment cleaner service.
     */
    public function createCleaner() {
        $cleaner = new EnvironmentCleanerService($this->container
            ->get('app.root'), Database::getConnection(), TestDatabase::getConnection(), $this->container
            ->get('messenger'), $this->container
            ->get('string_translation'), $this->container
            ->get('config.factory'), $this->container
            ->get('cache.default'), $this->container
            ->get('file_system'));
        return $cleaner;
    }

}

Members

Title Sort descending Modifiers Object type Summary
EnvironmentCleanerFactory::$container protected property The container.
EnvironmentCleanerFactory::createCleaner public function Factory method to create the environment cleaner service.
EnvironmentCleanerFactory::__construct public function Construct an environment cleaner factory.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.