You are here

public static function SettingsForm::create in CloudFlare 8

Instantiates a new instance of this class.

This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.

Parameters

\Symfony\Component\DependencyInjection\ContainerInterface $container: The service container this instance should use.

Overrides FormBase::create

File

src/Form/SettingsForm.php, line 81

Class

SettingsForm
Class SettingsForm.

Namespace

Drupal\cloudflare\Form

Code

public static function create(ContainerInterface $container) {

  // This is a hack because could not get custom ServiceProvider to work.
  // See: https://www.drupal.org/node/2026959
  $has_zone_mock = $container
    ->has('cloudflare.zonemock');
  $has_composer_mock = $container
    ->has('cloudflare.composer_dependency_checkmock');

  // Drupal\Component\Utility\EmailValidator introduced in 8.7.x. Adding
  // condition here for backward combatilibilty.
  // @see https://www.drupal.org/i/3038799
  if (class_exists('\\Drupal\\Component\\Utility\\EmailValidator')) {
    $email_validator = new EmailValidator();
  }
  else {
    $email_validator = new EguliasEmailValidator();
  }
  return new static($container
    ->get('config.factory'), $container
    ->get('cloudflare.state'), $has_zone_mock ? $container
    ->get('cloudflare.zonemock') : $container
    ->get('cloudflare.zone'), $container
    ->get('logger.factory')
    ->get('cloudflare'), $email_validator, $has_composer_mock ? $container
    ->get('cloudflare.composer_dependency_checkmock') : $container
    ->get('cloudflare.composer_dependency_check'));
}