function ContextDefinition::create

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::create()
  2. 10 core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::create()
  3. 11.x 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 83

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.