ActivationCheck.php 864 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Drupal\colorbox;
  3. use Drupal\Core\Config\ConfigFactoryInterface;
  4. use Symfony\Component\HttpFoundation\RequestStack;
  5. /**
  6. * Implementation of ActivationCheckInterface.
  7. */
  8. class ActivationCheck implements ActivationCheckInterface {
  9. /**
  10. * The colorbox settings.
  11. *
  12. * @var \Drupal\Core\Config\ImmutableConfig
  13. */
  14. protected $settings;
  15. /**
  16. * The request stack.
  17. *
  18. * @var \Symfony\Component\HttpFoundation\RequestStack
  19. */
  20. protected $request;
  21. /**
  22. * Create an instace of ActivationCheck.
  23. */
  24. public function __construct(ConfigFactoryInterface $config, RequestStack $request) {
  25. $this->settings = $config->get('colorbox.settings');
  26. $this->request = $request->getCurrentRequest();
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function isActive() {
  32. return $this->request->get('colorbox') !== 'no';
  33. }
  34. }