You are here

protected function ContextDefinition::dataTypeMatches in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::dataTypeMatches()
  2. 9 core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::dataTypeMatches()

Checks if this definition's data type matches that of the given context.

Parameters

\Drupal\Core\Plugin\Context\ContextInterface $context: The context to test against.

Return value

bool TRUE if the data types match, otherwise FALSE.

1 call to ContextDefinition::dataTypeMatches()
ContextDefinition::isSatisfiedBy in core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php
Determines if this definition is satisfied by a context object.

File

core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php, line 271

Class

ContextDefinition
Defines a class for context definitions.

Namespace

Drupal\Core\Plugin\Context

Code

protected function dataTypeMatches(ContextInterface $context) {
  $this_type = $this
    ->getDataType();
  $that_type = $context
    ->getContextDefinition()
    ->getDataType();
  return $this_type === 'any' || $this_type === $that_type || strpos($that_type, "{$this_type}:") === 0;
}