file CdnCacheTtlVersions.php

Namespace

Drupal\bootstrap\Plugin\Setting\Advanced\Cdn
  1. <?php
  2. namespace Drupal\bootstrap\Plugin\Setting\Advanced\Cdn;
  3. use Drupal\bootstrap\Plugin\Provider\ProviderInterface;
  4. use Drupal\Core\Access\AccessResultAllowed;
  5. use Drupal\Core\Form\FormStateInterface;
  6. /**
  7. * Due to BC reasons, this class cannot be moved.
  8. *
  9. * @todo Move namespace up one.
  10. */
  11. /**
  12. * The "cdn_cache_ttl_versions" theme setting.
  13. *
  14. * @ingroup plugins_setting
  15. *
  16. * @BootstrapSetting(
  17. * id = "cdn_cache_ttl_versions",
  18. * type = "select",
  19. * weight = 1,
  20. * title = @Translation("Available Versions"),
  21. * description = @Translation("The length of time to cache the CDN verions before requesting them from the API again."),
  22. * defaultValue = \Drupal\bootstrap\Plugin\Provider\ProviderInterface::TTL_ONE_WEEK,
  23. * groups = {
  24. * "cdn" = @Translation("CDN (Content Delivery Network)"),
  25. * "cdn_provider" = false,
  26. * "cache" = @Translation("Advanced Cache"),
  27. * },
  28. * )
  29. */
  30. class CdnCacheTtlVersions extends CdnCacheTtlBase {
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function access() {
  35. return parent::access()->andIf(AccessResultAllowed::allowedIf($this->getProvider()->supportsVersions()));
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. protected function getSettingValue(FormStateInterface $form_state) {
  41. return $this->getProvider()->getCacheTtl(ProviderInterface::CACHE_VERSIONS);
  42. }
  43. }

Classes

Name Description
CdnCacheTtlVersions The "cdn_cache_ttl_versions" theme setting.