You are here

class EventAnEnrollCacheContext in Open Social 10.0.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollCacheContext.php \Drupal\social_event_an_enroll\EventAnEnrollCacheContext
  2. 8.8 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollCacheContext.php \Drupal\social_event_an_enroll\EventAnEnrollCacheContext
  3. 10.3.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollCacheContext.php \Drupal\social_event_an_enroll\EventAnEnrollCacheContext
  4. 10.1.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollCacheContext.php \Drupal\social_event_an_enroll\EventAnEnrollCacheContext
  5. 10.2.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollCacheContext.php \Drupal\social_event_an_enroll\EventAnEnrollCacheContext

Defines a class for a anonymous event enrollment route context.

Hierarchy

Expanded class hierarchy of EventAnEnrollCacheContext

1 string reference to 'EventAnEnrollCacheContext'
social_event_an_enroll.services.yml in modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.services.yml
modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.services.yml
1 service uses EventAnEnrollCacheContext
cache_context.event_an_enroll_route in modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.services.yml
Drupal\social_event_an_enroll\EventAnEnrollCacheContext

File

modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollCacheContext.php, line 12

Namespace

Drupal\social_event_an_enroll
View source
class EventAnEnrollCacheContext implements CacheContextInterface {

  /**
   * Route match.
   *
   * @var \Drupal\Core\Routing\RouteMatchInterface
   */
  protected $routeMatch;

  /**
   * Constructs a new PreviewLinkCacheContext.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $routeMatch
   *   Route match.
   */
  public function __construct(RouteMatchInterface $routeMatch) {
    $this->routeMatch = $routeMatch;
  }

  /**
   * {@inheritdoc}
   */
  public static function getLabel() {
    return 'Is AN enrollment route';
  }

  /**
   * {@inheritdoc}
   */
  public function getContext() {
    return ($route = $this->routeMatch
      ->getRouteObject()) && $route
      ->getOption('_event_an_enroll_route') ?: FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata() {
    return (new CacheableMetadata())
      ->addCacheTags([
      'routes',
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EventAnEnrollCacheContext::$routeMatch protected property Route match.
EventAnEnrollCacheContext::getCacheableMetadata public function Gets the cacheability metadata for the context. Overrides CacheContextInterface::getCacheableMetadata
EventAnEnrollCacheContext::getContext public function Returns the string representation of the cache context. Overrides CacheContextInterface::getContext
EventAnEnrollCacheContext::getLabel public static function Returns the label of the cache context. Overrides CacheContextInterface::getLabel
EventAnEnrollCacheContext::__construct public function Constructs a new PreviewLinkCacheContext.