Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContextDefinition.php

function 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.

2 calls to ContextDefinition::create()
LayoutBuilderEntityViewDisplay::getContextsForEntity in core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
Gets the available contexts for a given entity.
NavigationRenderer::doBuildNavigation in core/modules/navigation/src/NavigationRenderer.php
Pre-render callback for ::buildNavigation.

File

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

Class

ContextDefinition
Defines a class for context definitions.

Namespace

Drupal\Core\Plugin\Context

Code

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal