You are here

public static function ContextDefinition::create 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::create()
  2. 9 core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::create()

Creates a new context definition.

Parameters

string $data_type: The data type for which to create the context definition. Defaults to 'any'.

Return value

static The created context definition object.

4 calls to ContextDefinition::create()
ContextAwarePluginTraitTest::setUp in core/tests/Drupal/KernelTests/Core/Plugin/Context/ContextAwarePluginTraitTest.php
ContextDefinitionTest::testCreateWithEntityDataType in core/tests/Drupal/KernelTests/Core/Plugin/ContextDefinitionTest.php
@covers ::create
LayoutBuilderEntityViewDisplay::getContextsForEntity in core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
Gets the available contexts for a given entity.
OverridesSectionStorageTest::testGetDefaultSectionStorage in core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php
@covers ::getDefaultSectionStorage

File

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

Class

ContextDefinition
Defines a class for context definitions.

Namespace

Drupal\Core\Plugin\Context

Code

public static function create($data_type = 'any') {
  if (strpos($data_type, 'entity:') === 0) {
    return new EntityContextDefinition($data_type);
  }
  return new static($data_type);
}