You are here

public static function ContextDefinition::create in Drupal 9

Same name and namespace in other branches
  1. 8 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.

5 calls to ContextDefinition::create()
ContextAwarePluginBaseTest::setUp in core/tests/Drupal/KernelTests/Core/Plugin/Context/ContextAwarePluginBaseTest.php
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);
}