Commit f1d4587b authored by Sam152's avatar Sam152 Committed by Sam152
Browse files

Issue #2646512 by Sam152: Inject the request stack into ActivationCheck

parent fce16807
services:
colorbox.activation_check:
class: Drupal\colorbox\ActivationCheck
arguments: ['@config.factory']
arguments: ['@config.factory', '@request_stack']
colorbox.attachment:
class: Drupal\colorbox\ColorboxAttachment
arguments: ['@colorbox.activation_check', '@module_handler', '@config.factory']
......@@ -7,8 +7,8 @@
namespace Drupal\colorbox;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\ConfigFactoryInterface;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Implementation of ActivationCheckInterface.
......@@ -22,25 +22,26 @@ class ActivationCheck implements ActivationCheckInterface {
*/
protected $settings;
/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $request;
/**
* Create an instace of ActivationCheck.
*/
public function __construct(ConfigFactoryInterface $config) {
public function __construct(ConfigFactoryInterface $config, RequestStack $request) {
$this->settings = $config->get('colorbox.settings');
$this->request = $request->getCurrentRequest();
}
/**
* {@inheritdoc}
*/
public function isActive() {
// Make it possible deactivate Colorbox with
// parameter ?colorbox=no in the url.
if (isset($_GET['colorbox']) && $_GET['colorbox'] == 'no') {
return FALSE;
}
else {
return TRUE;
}
return $this->request->get('colorbox') !== 'no';
}
}
Markdown is supported
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