You are here

public function ImmutableInvalidationBase::getProperty in Purge 8.3

Retrieve a purger specific property value.

Once ::setStateContext() has been called, purgers can call ::setProperty() and ::getProperty() to store specific metadata on the invalidation. The most common usecase for setting properties is for multi-step cache invalidation, for instance CDNs returning IDs to check against later.

Parameters

string $key: The key of the stored property, unique to the current purger context.

Return value

null|mixed The property value or NULL when no such property exists.

Throws

\LogicException Thrown when operating in general context, call ::setStateContext() first.

Overrides ImmutableInvalidationInterface::getProperty

File

src/Plugin/Purge/Invalidation/ImmutableInvalidationBase.php, line 100

Class

ImmutableInvalidationBase
Provides base implementations the immutable invalidation object.

Namespace

Drupal\purge\Plugin\Purge\Invalidation

Code

public function getProperty($key) {
  if (is_null($this->context)) {
    throw new \LogicException('Call ::setStateContext() before retrieving properties!');
  }
  if (isset($this->properties[$this->context][$key])) {
    return $this->properties[$this->context][$key];
  }
  return NULL;
}