Commit 4262c904 authored by m1r1k's avatar m1r1k Committed by vladan.me
Browse files

Fix response&controller classes set

parent 9565ed62
Readme file for the CAPTCHA module for Drupal
---------------------------------------------
[![Build Status](https://travis-ci.org/M1r1k/captcha.svg)](https://travis-ci.org/M1r1k/captcha)
captcha.module is the basic CAPTCHA module, offering general CAPTCHA
administration and a simple math challenge.
......
......@@ -137,8 +137,7 @@ function captcha_element_info() {
// Override the default CAPTCHA validation function for case
// insensitive validation.
// TODO: shouldn't this be done somewhere else, e.g. in form_alter?
if (CAPTCHA_DEFAULT_VALIDATION_CASE_INSENSITIVE == \Drupal::config('captcha.settings')
->get('captcha_default_validation', CAPTCHA_DEFAULT_VALIDATION_CASE_INSENSITIVE)) {
if (CAPTCHA_DEFAULT_VALIDATION_CASE_INSENSITIVE == \Drupal::config('captcha.settings')->get('captcha_default_validation')) {
$captcha_element['#captcha_validate'] = 'captcha_validate_case_insensitive_equality';
}
......
......@@ -15,6 +15,6 @@ image_captcha.font_preview:
image_captcha.generator:
path: '/image-captcha-generate/{session_id}/{timestamp}'
defaults:
_controller: '\Drupal\image_captcha\Controller\CaptchaImageGenerator::create'
_controller: '\Drupal\image_captcha\Controller\CaptchaImageGeneratorController::image'
requirements:
_permission: 'access content'
<?php
/**
* @file
* Contains CAPTCHA image response class.
*/
namespace Drupal\image_captcha\Controller;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\image_captcha\Response\CaptchaImageResponse;
use Drupal\Core\Config\Config;
class CaptchaImageGeneratorController implements ContainerInjectionInterface {
/**
* @var Config
*/
protected $config;
/**
* @var LoggerChannelInterface
*/
protected $logger;
/**
* @var resource
*/
protected $image;
/**
* {@inheritdoc}
*/
public function __construct(Config $config, LoggerChannelInterface $logger) {
$this->config = $config;
$this->logger = $logger;
}
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory')->get('image_captcha.settings'),
$container->get('logger.factory')->get('captcha')
);
}
public function image() {
return new CaptchaImageResponse($this->config, $this->logger);
}
}
......@@ -2,17 +2,17 @@
/**
* @file
* Contains CAPTCHA image generator controller class.
* Contains CAPTCHA image response class.
*/
namespace Drupal\image_captcha\Controller;
namespace Drupal\image_captcha\Response;
use Drupal\Core\Logger\LoggerChannelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Config\Config;
class CaptchaImageGenerator extends StreamedResponse {
class CaptchaImageResponse extends Response {
/**
* @var Config
......@@ -32,23 +32,13 @@ class CaptchaImageGenerator extends StreamedResponse {
/**
* {@inheritdoc}
*/
public function __construct($callback = NULL, $status = 200, $headers = array(), Config $config, LoggerChannelInterface $logger) {
public function __construct(Config $config, LoggerChannelInterface $logger, $callback = NULL, $status = 200, $headers = array()) {
parent::__construct(NULL, $status, $headers);
$this->config = $config;
$this->logger = $logger;
}
public static function create($callback = NULL, $status = 200, $headers = array()) {
return static::create(
$callback,
$status,
$headers,
\Drupal::config('image_captcha.settings'),
\Drupal::service('logger.factory')->get('captcha')
);
}
/**
* {@inheritdoc}
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment