CaptchaImageGeneratorController.php in CAPTCHA 8
File
image_captcha/src/Controller/CaptchaImageGeneratorController.php
View source
<?php
namespace Drupal\image_captcha\Controller;
use Drupal\Core\Config\Config;
use Drupal\Core\Database\Connection;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Psr\Log\LoggerInterface;
use Drupal\Core\PageCache\ResponsePolicy\KillSwitch;
use Drupal\image_captcha\Response\CaptchaImageResponse;
use Symfony\Component\DependencyInjection\ContainerInterface;
class CaptchaImageGeneratorController implements ContainerInjectionInterface {
protected $connection;
protected $config;
protected $fileSystem;
protected $logger;
protected $killSwitch;
public function __construct(Config $config, LoggerInterface $logger, KillSwitch $kill_switch, Connection $connection, FileSystemInterface $file_system) {
$this->config = $config;
$this->logger = $logger;
$this->killSwitch = $kill_switch;
$this->connection = $connection;
$this->fileSystem = $file_system;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory')
->get('image_captcha.settings'), $container
->get('logger.factory')
->get('captcha'), $container
->get('page_cache_kill_switch'), $container
->get('database'), $container
->get('file_system'));
}
public function image() {
$this->killSwitch
->trigger();
return new CaptchaImageResponse($this->config, $this->logger, $this->connection, $this->fileSystem);
}
}