You are here

class MediaParentEntityCacheContext in Media Parent Entity Link 8

Class MediaParentEntityCacheContext.

Hierarchy

Expanded class hierarchy of MediaParentEntityCacheContext

1 string reference to 'MediaParentEntityCacheContext'
media_parent_entity_link.services.yml in ./media_parent_entity_link.services.yml
media_parent_entity_link.services.yml
1 service uses MediaParentEntityCacheContext
cache_context.media_parent_entity in ./media_parent_entity_link.services.yml
Drupal\media_parent_entity_link\CacheContext\MediaParentEntityCacheContext

File

src/CacheContext/MediaParentEntityCacheContext.php, line 12

Namespace

Drupal\media_parent_entity_link\CacheContext
View source
class MediaParentEntityCacheContext implements CacheContextInterface {

  /**
   * Constructs a new MediaParentEntityCacheContext object.
   */
  public function __construct() {
  }

  /**
   * {@inheritdoc}
   */
  public static function getLabel() {
    \Drupal::messenger()
      ->addMessage('Lable of cache context');
  }

  /**
   * {@inheritdoc}
   */
  public function getContext($parententity = NULL) {
    return $parententity;
    if ($parententity !== NULL) {
      return $parententity
        ->bundle() . '-' . $parententity
        ->id();
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata() {
    return new CacheableMetadata();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MediaParentEntityCacheContext::getCacheableMetadata public function Gets the cacheability metadata for the context. Overrides CacheContextInterface::getCacheableMetadata
MediaParentEntityCacheContext::getContext public function Returns the string representation of the cache context. Overrides CacheContextInterface::getContext
MediaParentEntityCacheContext::getLabel public static function Returns the label of the cache context. Overrides CacheContextInterface::getLabel
MediaParentEntityCacheContext::__construct public function Constructs a new MediaParentEntityCacheContext object.