You are here

public function BlocacheMetadata::setBlock in Blocache (Block Cache Control) 8

Set the default cache metadata.

File

src/BlocacheMetadata.php, line 137

Class

BlocacheMetadata
Class BlocacheMetadata.

Namespace

Drupal\blocache

Code

public function setBlock(BlockInterface $block) {
  $this->block = $block;
  $this->defaults = [
    self::METADATA_MAX_AGE => $this->block
      ->getCacheMaxAge(),
    self::METADATA_CONTEXTS => $this->block
      ->getCacheContexts(),
    self::METADATA_TAGS => $this->block
      ->getCacheTags(),
  ];
  $this->overridden = $this->block
    ->getThirdPartySetting(self::MODULE, self::OVERRIDEN);
  $this->overrides = $this->block
    ->getThirdPartySetting(self::MODULE, 'metadata');
}